This is a very basic question, but I can't find an answer. I want to set an environment variable from the command prompt and then be able to access it globally (for instance, I should see it by going to system -> environment variables).

When I use the set command, it isn't accessible in a new cmd session.

set NEWVAR=SOMETHING
echo %NEWVAR%

Related questions:

link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

To make the environment variable accessible globally you need to set it in the registry. As you've realised by just using:

set NEWVAR=SOMETHING

you are just setting it in the current process space.

According to this page you can use the setx command:

setx NEWVAR SOMETHING

which is only available if you install the Windows Resource Kit

link|improve this answer
2  
It turns out that setx is also built into windows 7. – Shane Mar 25 '10 at 11:30
1  
You don't use equal sign with setx. – Piotr Dobrogost Oct 15 '11 at 18:33
@PiotrDobrogost - thanks - I could have sworn I saw it in the example I copied. – ChrisF Oct 15 '11 at 18:51
@ChrisF No problem. We all know this feeling :) – Piotr Dobrogost Oct 15 '11 at 19:14
feedback

In Windows, just like in Unix-based OSes, a process can only change environment of its own, also create processes that get a copy of its environment.

link|improve this answer
1  
...as well as change global system settings which are source of initial environment for every new process :) – Piotr Dobrogost Oct 15 '11 at 19:18
feedback

Your Answer

 
or
required, but never shown

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