How to Open, Add, and Edit Environment Variables in Windows 11

To open environment variables in Windows 11, press Windows + R, type sysdm.cpl, and press Enter, then select Environment Variables on the Advanced tab. You can also search the Start menu for Edit the system environment variables, which opens the same window.

These steps cover Windows 11 Home, Pro, and Enterprise. The Environment Variables window and the commands below are the same in Windows 10.

An environment variable is a named value, such as a folder location, that Windows and programs read when they start. The Path variable is the one most people need: it is the list of folders Windows checks when you type a command like python or java. Microsoft explains how they work in its environment variables documentation.

User Variables vs. System Variables

The Environment Variables window has two lists, and picking the right one matters.

List Applies to Admin rights needed? Good for
User variables for (your name) Only your account No Tools only you use, like a personal script folder
System variables Every account on the PC Yes Tools all users need, like a shared JDK

When a program starts, Windows combines both lists. For Path, the system entries come first and your user entries are added after them. If you are not sure which to use, start with the user list: it does not need administrator rights and cannot break other people’s accounts.

How to Open the Environment Variables Window

Method 1: The Run Box (Fastest)

  1. Press Windows + R, or right-click Start and select Run.
  2. Type sysdm.cpl and select OK. The System Properties window opens.
  3. Select the Advanced tab.
System Properties Advanced tab with the Environment Variables button highlighted at the bottom
On the Advanced tab of System Properties, select Environment Variables. (Recreated interface)
  1. Select Environment Variables at the bottom.
Windows 11 Environment Variables window with user and system variable lists
User variables apply to your account. System variables apply to everyone.

The Environment Variables window opens with your user variables at the top and System variables at the bottom. This route shows both lists, and you can edit the system list if your account is an administrator.

Method 2: Start Menu Search

  1. Select Start and type environment.
  2. Select Edit the system environment variables to reach both lists. The System Properties window opens on the Advanced tab.
Windows Search detail for environment with Edit the system environment variables highlighted as the best match
Search for environment and select Edit the system environment variables. (Recreated interface)
  1. Select Environment Variables.

The other result, Edit environment variables for your account, opens a version of the window where only your user variables can be changed. It works on a standard account without an administrator password.

Method 3: The Settings App

  1. Press Windows + I to open Settings.
  2. Go to System > About. You can also press Windows + X and select System.
  3. Select Advanced system settings. It is a link near Device specifications.
Windows Settings System About Related links detail with Advanced system settings highlighted
On System → About, look for Advanced system settings, sometimes under Related links. The link’s position and the device-information heading vary by Windows build. (Recreated interface)
  1. Select Environment Variables.

On a Standard (Non-Admin) Account

Use Edit environment variables for your account from Start search. If you open Advanced system settings instead, Windows asks for an administrator’s password. Be careful here: after someone types an admin password, the top list shows that administrator’s user variables, not yours, so a change you make there will not appear in your own account.

Back Up Before You Change Anything

Windows keeps no undo history for environment variables. Before a big Path edit, export both lists to your desktop from Command Prompt:

  • User variables: reg export HKCU\Environment "%USERPROFILE%\Desktop\user-env.reg"
  • System variables: reg export "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" "%USERPROFILE%\Desktop\system-env.reg"

To restore one, run reg import with the file’s path (use an administrator window for the system file), then open a new terminal. A copy of the old value pasted into Notepad also works for a single variable.

How to Edit the Path Variable

  1. In the Environment Variables window, select Path in the user list or the System variables list.
  2. Select Edit. The Edit environment variable window opens with one folder per line.
Windows 11 Edit environment variable window listing Path folders with New and Move Up buttons
Each Path folder sits on its own line. Use Move Up to give a folder priority.
  1. Select New and paste the folder path, such as C:\Tools\bin. You can select Browse instead to pick the folder and avoid typing mistakes.
  2. Select OK in each of the three windows to save.
Steps to edit the Path environment variable in Windows 11
Illustration: how to edit the Path environment variable in Windows 11.
  1. Open a new Command Prompt window and run echo %PATH%. The folder you added appears at the end of the list.

A few rules make Path edits work the first time:

  • Add folders, not files. Enter C:\Tools\bin, not C:\Tools\bin\tool.exe.
  • Order matters. Windows runs the first matching program it finds. If an old Python or Java version keeps running, select the newer folder and use Move Up until it sits above the old one, or Delete the old entry.
  • Use OK, not the X. Closing the windows with the X button throws away your changes.
  • Edit text shows the whole value as one line separated by semicolons. Use it only when you need to paste a full list.

Java development is a practical example: JAVA_HOME identifies the JDK’s main folder, while Path lets Windows find commands in its bin folder. This Java installation guide for Windows 11 explains how to choose the required version, configure those values, and check which installation your terminal is using.

Python is another common case. Read about installing Python on Windows 11 to see which folder the Python Install Manager uses for its commands. Apache Maven works the same way, and the key Path step when installing Maven on Windows 11 is adding the bin folder of the extracted Maven folder.

How to Add a New Variable

  1. Under the user list or System variables, select New.
  2. Type a Variable name, such as JAVA_HOME. Names cannot contain an equals sign (=).
  3. Type the Variable value, or select Browse Directory or Browse File to fill it in.
New User Variable dialog in Windows 11 with JAVA_HOME entered as the variable name
Name the variable, then type or browse to its value.
  1. Select OK in each window.

Enter the value in the format the program that reads it expects. Path is a semicolon-separated list of folders, but most other variables hold a single folder, file, or setting. You can also refer to one variable inside another: adding %JAVA_HOME%\bin to Path means you only update JAVA_HOME when you install a new JDK.

How to Change or Delete a Variable

  • Change: select the variable, select Edit, change the name or value, and select OK in each window.
  • Delete: select the variable and select Delete, then OK. There is no confirmation message and no undo button, so copy the value into Notepad first if you might need it again.

Do not delete system variables you did not create, such as ComSpec, TEMP, or windir. Windows and installed programs depend on them.

Make Sure the Change Took Effect

Programs read environment variables only when they start. A Command Prompt, PowerShell, or Terminal window that was already open keeps the old values.

  1. Close every terminal window and any app that needs the new value.
  2. Open a new Command Prompt and run echo %VARIABLE_NAME%, for example echo %JAVA_HOME%. In PowerShell, run $env:JAVA_HOME.
  3. If the window prints the name back, like %JAVA_HOME%, the variable is not set for that window. Check the spelling and which list you used.
Command Prompt showing echo JAVA HOME returning a JDK 25 folder and an unset MY VAR returning its literal percent-sign name
In a new Command Prompt, run echo %JAVA_HOME% to check the value. The unset MY_VAR prints back as %MY_VAR%. (Recreated interface)
  1. If an app started from the taskbar still sees the old value, sign out and back in, or restart the PC.

Set Variables From Command Prompt or PowerShell

The command line is handy for scripts or when you only need a value for one session.

Task Command Prompt PowerShell
Show one variable echo %PATH% $env:Path
List all variables set Get-ChildItem Env:
Set for this window only set MY_VAR=C:\Tools $env:MY_VAR = "C:\Tools"
Save a user variable setx MY_VAR "C:\Tools" [Environment]::SetEnvironmentVariable("MY_VAR", "C:\Tools", "User")
Save a system variable (admin window) setx MY_VAR "C:\Tools" /M [Environment]::SetEnvironmentVariable("MY_VAR", "C:\Tools", "Machine")
Remove a saved variable Use the Environment Variables window [Environment]::SetEnvironmentVariable("MY_VAR", "", "User")

Saved values appear only in windows you open afterward, not in the window where you ran the command. The system-wide commands fail with an access error unless you run Command Prompt as an administrator or open PowerShell the same way.

Do not use setx to change Path. Microsoft’s setx documentation says it cuts values longer than 1,024 characters and saves the shortened text, which can wipe out folders on a busy PC. It also replaces references like %JAVA_HOME% with their current text. Use the Environment Variables window for Path instead. PowerShell’s options are described in Microsoft’s about_Environment_Variables page.

Another Option: PowerToys Environment Variables

Microsoft’s free PowerToys app includes an Environment Variables utility with a cleaner editor and named profiles, which are sets of variables you can switch on and off together. It shows the combined result of all lists in an Applied variables view. Editing system variables there requires its Open as administrator setting, which is on by default. The built-in window does everything most people need, so PowerToys is optional.

When Buttons Are Gray or Commands Aren’t Recognized

The System Variables Buttons Are Greyed Out

You are on a standard account or opened Edit environment variables for your account. Open sysdm.cpl from an administrator account, ask an administrator to make the change, or put the value in your user list instead.

“Is Not Recognized as an Internal or External Command”

Windows cannot find the program in any Path folder. Check that the entry points to the folder that holds the .exe file, not to the file itself, and that you opened a new window after saving. Typing where toolname in Command Prompt shows which copy Windows finds, if any. That is also why node or npm may not be recognized right after installing Node.js.

The Wrong Version of a Tool Runs

Two Path folders contain a program with the same name. Move the folder you want higher in the list, or remove the old one. Remember that system Path entries come before user entries.

Path Got Shorter After Using setx

Restore your backup with reg import, or rebuild the missing folders in the Path editor. Use the window, not setx, for future Path changes.

Environment Variable Questions

Should I put a folder in the user Path or the system Path?

Use the user Path for tools only you run, because it needs no admin rights and affects no one else. Use the system Path when every account on the PC needs the tool.

Do I have to restart my PC after changing an environment variable?

Usually not. Close and reopen the terminal or app that needs the change. Sign out or restart only if an app launched from the taskbar still sees the old value.

Where does Windows store environment variables?

In the registry. User variables are under HKEY_CURRENT_USER\Environment, and system variables are under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment. Edit them through the Environment Variables window rather than Registry Editor.

Can I undo a change?

Only by putting the old value back yourself, from your Notepad copy or exported .reg file. That is why a backup before editing Path is worth the minute it takes.

Why can’t I edit system variables?

If you opened the “for your account” window, it only shows user variables. Use sysdm.cpl to reach both lists, and make sure you’re signed in with an administrator account.

Related: How to Open the Run Command in Windows 11 and How to Install WSL2 on Windows 11.