The "set" command

Soldato
Joined
18 Oct 2002
Posts
8,304
Location
The Land of Roundabouts
Need some help please!!
Im trying to install an Apache/Axis server, Apache is as easy as ever!
The problem i get is after installing Java and run the following command

set JAVA_HOME=C:\Program Files\Java
Which is fine, no errors given.
But when i come to try
cd %JAVA_HOME%

It cant find the path :confused: The path given in the set command is correct and valid!

am i missing something here?
 
i don't think that setting persists? i'd right click my computer, properties, advanced, environment variables. under system, click "new" and do it that way.
 
Code:
C:\>set JAVA_HOME=C:\Program Files\Java

C:\>cd %JAVA_HOME%

C:\Program Files\Java>

works fine on my machine.. are you sure the directory actually exists? :p
Also, may need to quote due to the space etc..
 
You'll need to wrap either the path within the environment variable or in the cd command in double quotes to deal with the space in the path:

set JAVA_HOME="C:\Program Files\Java"
 
yep defiantly exists :)
Ive tried with/without quotes, "program files" as progra~1 and what Marc posted (cheers btw)

Still no joy............
My colleague just tried it and it worked for them :confused:

**Goes off to kick manager who wanted it on a Windows machine**
 
i don't think that setting persists? i'd right click my computer, properties, advanced, environment variables. under system, click "new" and do it that way.
That's just what I was gonna suggest.

It's also confirmed here... http://www.ss64.com/nt/set.html

Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.

Permanent Changes

Changes made using the SET command are NOT permanent, they apply to the current CMD prompt only and remain only until the CMD window is closed.
To permanently change a variable at the command line use SetX
or in the GUI - Control Panel, System, Environment, System/User Variables

Changing a variable permanently with SetX will not affect any CMD prompt that is already open.
Only new CMD prompts will get the new setting.

You can of course use SetX in conjunction with SET to change both at the same time, but neither SET or SetX will affect other CMD sessions that are already running. When you think about it - this is a good thing.

It is also possible (although undocumented) to add permanent env variables to the registry [HKEY_CURRENT_USER\Environment]
(using REGEDIT) System Environment variables can also be found in [HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
 
Back
Top Bottom