Registry value with quotes

╄→尐↘猪︶ㄣ 提交于 2019-12-02 06:35:55

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!