Everybody say that \ works as an escape inside reg.exe like:
The REG command will interpret \ as an escape for the character that immediately follows it. source
but I found it not a full correct rule. see this examples please:
escaping a character does not work:
reg add HKCU\testt /f /v "" /t REG_EXPAND_SZ /d "a\b"
===> a\b
escaping the escape does not work:
reg add HKCU\testt /f /v "" /t REG_EXPAND_SZ /d "a\\b"
===> a\\b
reg add HKCU\testt /f /v "" /t REG_EXPAND_SZ /d "a\\b"
===> a\\b
but when I escape a double quote " then escaping the escape will work:
reg add HKCU\testt /f /v "" /t REG_EXPAND_SZ /d "a\\\"b"
===> a\"b
conclusion:
\ works as an escape only if I escape a double quote "
and more strange is this, escape the escape does not work even when I escape a double quote:
reg add HKEY_CURRENT_USER\testt /f /v "" /t REG_EXPAND_SZ /d "a\\ \"b"
===> a\\ "b
this means that to escape the escape it have to be adjacent to the escaped double quote!!
is this a correct behavior? where is this documented if it is correct?
the examples were done on win7 using cmd.