I need to insert a value into registry in a batch file. The value contains quotes and that makes it hard to insert.
set OPENCOMMAND="\"%JAVAHOME%\bin\javaw.exe\" -jar \"%%1\" %%*\""
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command" /v "" /t REG_SZ /d %OPENCOMMAND%
This results almost in the correct result except that the value contains quotes around it in the reqistry.
"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*"
That's what the registry contains and what it should contain is
C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
What to do?
This script should work:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command" /v "" /t REG_SZ /d "\"%JAVAHOME%\bin\javaw.exe\" -jar \"%%1\" %%*"
来源:https://stackoverflow.com/questions/12822801/registry-value-with-quotes