Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to set three environment variables and append them to the machine path. Right now my code is like this:

setx CATALINA_HOME "C:\Program Files (x86)\Apache Software Foundation\Tomcat 7" /m
setx JRE_HOME "C:\Program Files (x86)\Java\jre7" /m
setx JAVA_HOME "C:\Program Files (x86)\Java\jdk1.7.0_21" /m
setx PATH "%PATH%;%JAVA_HOME%\bin;%JRE_HOME%\bin;%CATALINA_HOME%\BIN;" /m

The first three when run alone work fine for adding the variable. However, the last line is resulting in the deletion of part of the original path and none of the additional variables appended.

My desired result would be the addition of the three variables and for the system-wide path to be

[original path];%JAVA_HOME%\bin;%JRE_HOME%\bin;%CATALINA_HOME%\BIN;
share|improve this question
add comment

1 Answer

Part of your problem is that SETX isn’t SET –– after you do

setx JAVA_HOME "C:\Program Files (x86)\Java\jdk1.7.0_21" /m

…, %JAVA_HOME% isn’t set in that instance of the Command Prompt.  You’d have to start a new instance to get %JAVA_HOME%, et. al., set.  I suggest you do something like

set  JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_21
setx JAVA_HOME "%JAVA_HOME%" /m

I don’t see why you would be deleting part of the original path.  Access/modify the User path variable, not System path may be relevant.  And you might want to do

reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v path

to get the system part of the PATH variable, excluding the user part.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.