To open environment variables in Windows 10, type environment in the search box and select Edit the system environment variables. Then select Environment Variables. Use New or Edit under User variables for your account, or under System variables for everyone on the PC.
Applies to: Windows 10. Checked against Microsoft Learn on September 25, 2026.
Open the Environment Variables window
- Type environment in the search box on the taskbar.
- Select Edit the system environment variables. Select Yes if asked.
- On the Advanced tab, select Environment Variables.

You can also press Windows logo key + R, type sysdm.cpl, and open the Advanced tab. To change only your own variables without admin rights, search for Edit environment variables for your account instead.
Add or edit a variable
- Under User variables or System variables, select New to add a variable, or select one and choose Edit.
- Enter the Variable name, such as
JAVA_HOME, and the Variable value, such as the folder it points to. - Select OK in each window.

User variables apply only to your account. System variables apply to every account and need admin rights.
Add a folder to PATH
- Select Path and select Edit.
- Select New and paste the folder, such as
C:\Tools\bin. - Select OK in each window.
Don’t delete existing entries in Path. Removing one can stop apps from starting. A missing entry is also a common reason the python command is not recognized, which our guide on how to install Python in Windows 10 covers in its troubleshooting section.
Set a variable from Command Prompt
Run setx to save a variable for your account:
setx JAVA_HOME "C:\Program Files\Contoso\jdk-21"
setx saves the value permanently, but only new windows see it. To set a system variable, open Command Prompt as administrator and add /M at the end. Avoid using setx on Path, because long values can be cut off.
Set a variable with PowerShell
PowerShell can save a variable permanently without the length limit of setx. For your account, run:
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Contoso\jdk-21", "User")
Use “Machine” instead of “User” for a system variable, in a PowerShell window opened as administrator. As with setx, open a new window to see the change.
Set a variable for one window only
For a quick test that disappears when you close the window, use set MYVAR=hello in Command Prompt or $env:MYVAR = "hello" in PowerShell. Nothing is saved to Windows.
User variables vs. system variables
User variables apply only to your account. System variables apply to everyone on the PC and to services. When both define the same name, the user value wins, except for Path, where Windows joins the system Path and your user Path together. Put personal tools in your user Path so you don’t need administrator rights.
Troubleshooting
- “is not recognized as an internal or external command.” The folder containing the program isn’t in Path, or you added the wrong folder. Add the folder that holds the .exe itself, then open a new window.
- The Path editor shows one long line instead of a list. Your Path probably doesn’t start with a normal folder. Edit carefully, keeping each folder separated by a semicolon.
- The System variables buttons are greyed out. You need an administrator account. Ask the PC’s owner, or use your user variables instead.
- A program finds the wrong version. Windows uses the first match in Path. Use Move up in the Path editor to put the folder you want first.
Frequently asked questions
I changed a variable, but my app doesn’t see it.
Close and reopen the app, Command Prompt, or PowerShell. Some apps need you to sign out and back in.
How do I see a variable’s value?
In Command Prompt, run echo %JAVA_HOME%. In PowerShell, run $env:JAVA_HOME. See how to open Command Prompt in Windows 10.
Changing system variables needs administrator rights. See how to run a program as administrator in Windows 10.
For other ways to open this window, see how to open System Properties in Windows 10.
Microsoft’s C compiler sets up its own paths in the Developer Command Prompt, so you don’t need to add them here. See how to compile and run a C program in Windows 10.
If you install the JDK from Microsoft, its installer can set JAVA_HOME and PATH for you. See how to install the JDK on Windows 10.
If you remove a coding tool, check whether it left any paths here. See how to uninstall Eclipse IDE on Windows 10.
Python’s installer can add itself to PATH for you. See how to install Python on Windows 10.
Microsoft’s reference is setx. More help is on our Windows Help & Guides page.
Related: install OpenSSL on Windows 10.
Related: How to Change the Java Version in Windows 10.
Related: how to install JMeter on Windows 10.
Related: how to install PHP in Windows 10.

Matt Jacobs has been working as an IT consultant for small businesses since receiving his Master’s degree in 2003. While he still does some consulting work, his primary focus now is on creating technology support content for SupportYourTech.com.
His work can be found on many websites and focuses on topics such as Microsoft Office, Apple devices, Android devices, Photoshop, and more.