Open System Properties
Press Win + R
, type sysdm.cpl
, and hit Enter.
Go to Environment Variables
In the “System Properties” window, click the Advanced tab, then hit the Environment Variables button at the bottom.
Create or Edit Variables
For a user variable, select your name under the top list.
For a system-wide variable, use the bottom list (requires admin rights).
Click New to create a variable, or Edit to modify an existing one.
Input Details
Set the Variable Name (e.g., MY_VAR
) and Variable Value (e.g., C:\MyPath
).
Click OK to save and close all dialogs.
set MY_VAR=C:\MyPath
setx MY_VAR "C:\MyPath"
setx
writes to the registry, so the variable persists across sessions.
Note: Changes from setx
won't be visible in the current session—you'll need to restart your terminal.
In Command Prompt:
echo %MY_VAR%
Or use SystemPropertiesAdvanced.exe
to visually confirm from the GUI.
Want to script this via PowerShell or roll it into a batch operation? I can help craft something precise for you.