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

Answer from ChrisF on Stack Exchange
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows-server › administration › windows-commands › set_1
set (environment variable) - Windows commands
If you use the set command without any parameters, the current environment settings are displayed. These settings usually include the COMSPEC and PATH environment variables, which are used to help find programs on disk. Two other environment variables used by Windows are PROMPT and DIRCMD.
🌐
Twilio
twilio.com › en-us › blog › how-to-set-environment-variables-html
How to Set Environment Variables | Twilio
December 9, 2025 - Consult the Microsoft documentation on PowerShell environment variables for more details. Cmd, otherwise known as cmd.exe and the Command Prompt also comes with all installations of Windows. You should probably use PowerShell, but if you can't, here's how you can set environment variables from cmd and batch files.
Discussions

command line - Set Environment Variables Windows - Stack Overflow
First off, I'd like to apologise if this has already been covered. It's difficult to filter through all the existing issues similar to this one. So in Windows there is two (as far as I'm aware) wa... More on stackoverflow.com
🌐 stackoverflow.com
Environment Variable Setting via Command Line
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. More on community.spiceworks.com
🌐 community.spiceworks.com
3
6
July 28, 2022
Is there a way to set environment variables that only apply to the command prompt (but to all future sessions)?
I think you can create a batch file that sets the environment variables, and launch it with cmd.exe /k "C:\path\setvars.bat" More on reddit.com
🌐 r/Windows10
5
0
April 14, 2021
Set environment variable for one command on command line
You use FOO=bar command just as you would in Bash. It’s not a “bashism”, it’s common for all Bourne-type shells. More on reddit.com
🌐 r/zsh
13
5
April 4, 2022
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to set environment variable in windows
How to Set Environment Variables in Windows
December 9, 2025 - To add a system-wide environment variable, open the Command Prompt as administrator and use: ... To unset an environment variable using the GUI, follow the steps in the section on setting environment variables via GUI to reach the Environment Variables window.
🌐
SS64
ss64.com › nt › syntax-variables.html
Windows Environment Variables - Windows CMD
For example, if the SET command is used to modify the PATH, or if it is removed completely with PATH ; that will affect the current process, but not any other programs or CMD sessions opened before or after the current one. This precedence is important to understand because if you try to set a System Environment variable PATH = %APPDATA%;C:\Windows, it will fail because the %APPDATA% Shell variable is not created until after the System environment variables are imported to the session.
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows-server › administration › windows-commands › setx
setx | Microsoft Learn
February 3, 2023 - The Setx command also retrieves the values of registry keys and writes them to text files. ... This command provides the only command-line or programmatic way to directly and permanently set system environment values.
🌐
Windows 10 Forums
tenforums.com › tutorials › 3234-environment-variables-windows-10-a.html
Environment Variables in Windows 10 - Windows 10 Help Forums
December 11, 2014 - User environment variables are ...E\SYSTEM\CurrentControlSet\Control\Session Manager\Environment You can open a command prompt, type set, and press Enter to display all current environment variables on your PC....
🌐
Computer Hope
computerhope.com › issues › ch000549.htm
How to Set the Path and Environment Variables in Windows
You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New, and enter the variable name and value. ... To view and set the path through the Windows command line, use the path command.
🌐
Sigasi
sigasi.com › knowledge › how_tos › setting-environment-variables
Setting Environment Variables - Sigasi
September 23, 2024 - Click on Advanced system settings on the left side. In the System Properties window, click on Environment Variables. In the User variables or System variables section: Click New to add a new variable. Click Edit to modify an existing variable. Click Delete to remove a variable. Enter the variable name and value, then click OK. Note: User variables apply only to the current user, while system variables apply to all users on the machine. Open Command Prompt or PowerShell with administrator rights.
🌐
NinjaOne
ninjaone.com › home › blog › it ops › how to view and manage environment variables in windows
How to View and Manage Environment Variables In Windows | NinjaOne
March 12, 2026 - To define a temporary variable (valid only for the session): Type set MY_VAR=TestValue and press Enter. This is ideal for temporary overrides or script-based testing. However, it won’t persist once you close the Command Prompt.
🌐
NTU Singapore
www3.ntu.edu.sg › home › ehchua › programming › howto › Environment_Variables.html
Environment Variables in Windows/macOS/Linux
(For Java) You can set the CLASSPATH environment variables by adding the following line. For example, export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar · Take note that Bash shell uses colon (:) as the path separator; while windows use semicolon (;). To refresh the bash shell, issue a "source" command (or re-start the bash shell):
🌐
Foundry
learn.foundry.com › nuke › 13.2 › content › comp_environment › configuring_nuke › environment_variables.html
Setting Environment Variables - Foundry Learn
In both cases, VARIABLE should be replaced by the environment variable you're interested in. For example, NUKE_TEMP_DIR on Windows returns: ... If the variable is set, its value is displayed in the command window.
🌐
GitHub
gist.github.com › mitchmindtree › 92c8e37fa80c8dddee5b94fc88d1288b
How to permanently set user environment variables on Windows · GitHub
Using the command prompt: setx FOO "path\to\foo" Using powershell: [Environment]::SetEnvironmentVariable("FOO", "path\to\foo", [System.EnvironmentVariableTarget]::User) Using the windows GUI.
🌐
Dowdandassociates
dowdandassociates.com › blog › content › howto-set-an-environment-variable-in-windows-command-line-and-registry
HowTo: Set an Environment Variable in Windows - Command Line and Registry - Dowd and Associates
December 2, 2011 - You can use environment variables in the values of other environment variables. It is then helpful to be able to see what environment variables are set already. This is how you do it: ... To set persistent environment variables at the command line, we will use setx.exe.
🌐
Launch School
launchschool.com › books › command_line › read › environment
How to Change your Command Line Environment
While there are several environment variables that are set for you automatically, you can also set your own or modify existing variables. You can do this on the fly, so that your changes only affect the current command or the current session, or you can make the changes more permanent so that they stick between sessions. Note: The term "session" refers to the state of being logged in to a computer's command line interface.
🌐
Autodesk
autodesk.com › support › technical › article › caas › sfdcarticles › sfdcarticles › How-to-set-an-environment-variable.html
How to set an environment variable
You don't have permission to access "http://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/How-to-set-an-environment-variable.html" on this server.