Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a system environment variable in Windows XP without using the "My Computer" Dialog

Tags:

windows

I'm switching between different Java SDKs (1.4.2, 1.5.0 and 1.6.0) for various projects. I would like to set the JAVA_HOME environment variable on my Windows XP machine without going through the tedious My Computer -> Advanced -> [Select System Variable] -> Edit -> Ok -> Ok

Is it possible to do this from the command line, or is there a utility that can do this?

(Note that I am not referring to the standard batch file "SET" command - I want to set the environment variable "globally," not just for the life of a console window).

like image 344
noahlz Avatar asked Dec 01 '08 19:12

noahlz


People also ask

How do I set environment variables manually?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

How do I set environment variable in CMD?

2.2 Set/Unset/Change an Environment Variable for the "Current" CMD Session. To set (or change) a environment variable, use command " set varname=value ". There shall be no spaces before and after the '=' sign. To unset an environment variable, use " set varname= ", i.e., set it to an empty string.

How do I set an environment variable in Windows without admin rights?

Control Panel -> User Accounts -> User Accounts -> Change my environment variables (left side). This will open the user variables without admin access allowing the user's variables to be edited. Make sure the user account's name is showing where the red circle is. Save this answer.


2 Answers

From http://vlaurie.com/computers2/Articles/environment.htm:

Using the add-on tool Setx.exe

It is not part of the standard Windows XP setup but a command-line tool called setx.exe is included in the Windows XP Service Pack 2 Support Tools. This tool extends the set command so that permanent changes in the environment variables can be made. For example, to add a folder C:\New Folder to the path, the command would be setx path "%PATH%;C:\New Folder"

like image 102
Dirk Vollmar Avatar answered Nov 03 '22 00:11

Dirk Vollmar


Service Pack 2 Support Tools has a tool called "setx.exe" that can do what you are looking for. setx path "%PATH%;C:\New Folder"

Source

like image 41
joegtp Avatar answered Nov 02 '22 23:11

joegtp