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
command line - Set Environment Variables Windows - Stack Overflow
Environment Variable Setting via Command Line
Is there a way to set environment variables that only apply to the command prompt (but to all future sessions)?
Set environment variable for one command on command line
Videos
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
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.
Here’s how I’ve done it many times via command line. Run setx /? at a cmd prompt for all the options. /M makes it a system wide variable.
Ex.
ORACLE_HOME is the variable name.
The C:\ path is the value of the variable.
SETX ORACLE_HOME C:\Oracle\product\11.2.0\instantclient_11_2 /M
Is there a command line I can use to set PC and Server environment variables? I have several I have to type in often. It would be nice to write a script to enter them for me.