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"
When working at the command line or with batch files, you must take one of two actions when you use strings that contain an ampersand. Either you must escape the ampersand by using the caret (^) symbol, or you must enclose the string inside quotation marks.
The Setx command also retrieves the values of registry keys and writes them to text files. This command provides the only command-line or programmatic way to directly and permanently set system environment values. System environment variables are manually configurable through Control Panel or through a registry editor.
On commandline use ^
to escape, like so
^%JAVA_HOME^%
In batch file, use %
to escape, like so
%%JAVA_HOME%%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With