Is there a way to set Windows environment variables from the command line PERMANENTLY

8

4

Possible Duplicate:
Setting and getting windows environment variables from the command prompt?

Is there any way to set permanently set an environment variable system wide from the command line in Windows?

something like

>systemset newVar=foo

or a file to edit would work well too.

ScottS

Posted 2010-03-14T18:54:55.720

Reputation: 183

Question was closed 2011-10-15T11:07:58.657

Answers

11

You can use the MS utility "Setx" to make permanent changes form the command-line.

Here's a direct link to the Windows 2000 version (works in XP, etc.).

You can also get it in the Windows XP SP2 Support Tools pack.

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"

Ƭᴇcʜιᴇ007

Posted 2010-03-14T18:54:55.720

Reputation: 103 763

2It's part of Windows since at least Vista, though. – Joey – 2010-03-14T19:05:06.140

Good point, forgot to mention that. :) – Ƭᴇcʜιᴇ007 – 2010-03-14T19:22:44.860

It is possible to do the same from System Properties > Advanced > Environment Variables, or registry HKCU\Environment. – user1686 – 2010-03-15T14:52:13.877