Setting and getting Windows environment variables from the command prompt?

Solution 1:

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

setx is built into Windows 7, but for older versions may only be available if you install the Windows Resource Kit

Solution 2:

We can also use "setx var variable /M" to set the var to system environment variable level instead of user level.

Note: This command should be run as administrator.