I need to quote arbitrary arguments in a Windows 10 batch file, and I'm having problems when they end in a backslash.
Let's say I want to call Robocopy to copy *.foo files from A:\ to B:\ like this:
robocopy A:\ B:\ *.foo
But really I'm getting A:\ as an argument (let's say I use %~1, and I don't know if it contains spaces, so I quote it:
robocopy "%SOURCE%" B:\ *.foo
Unfortunately if %SOURCE% ends with a backslash, the last \ is considered an escape character, escaping ".
robocopy "A:\" B:\ *.foo
So Windows thinks the first argument is "A:" B:\ *.foo.
How can I turn off interpretation of \" as an escape sequence?
reg add "HKCU\Environment" /v MyRegTest /t REG_SZ /d "%TEMP%\" /f. The user is prompted on second run although there is/fat end. But runreg query "HKCU\Environment" /v MyRegTestand it can be seen what was really added on first run. Run lastreg delete "HKCU\Environment" /v MyRegTest /fto remove the added user environment variable with a value ending with" /fnot expected by most users.