Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to escape % at cmd setx?

Tags:

window

cmd

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"

like image 613
atian25 Avatar asked Jun 19 '11 00:06

atian25


People also ask

How do I escape from command prompt?

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.

What is the Setx command?

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.


1 Answers

On commandline use ^ to escape, like so

^%JAVA_HOME^%

In batch file, use % to escape, like so

%%JAVA_HOME%%
like image 165
manojlds Avatar answered Nov 03 '22 00:11

manojlds