how to escape % at cmd setx?

2019-04-28 09:23发布

问题:

I'm trying to set var by cmd script, but got some problem,

setx /M JAVA_HOME "D:\Tool\JDK"
setx /M PATH "%PATH%;%JAVA_HOME%\bin;D:\TZProfile\!!!QuickLink\"

I want to add %JAVA_HOME%\bin to PATH, no "D:\Tool\JDK"

回答1:

On commandline use ^ to escape, like so

^%JAVA_HOME^%

In batch file, use % to escape, like so

%%JAVA_HOME%%


标签: window cmd