How To Edit Environment Variables And PATH In Windows 11 (2026)
Short answer: select Start, type environment properties, and press Enter to open System Properties.
Select Environment Variables, choose a variable, and select Edit, or double-click Path and select New to add a folder.
Select OK in every window, then open a new Command Prompt or PowerShell window to use the change.
Quick answer: pick a method
| Goal | Method |
|---|---|
| Add a folder to PATH or change a variable | System Properties, Environment Variables window |
| Use a form with profiles | PowerToys Environment Variables |
| Set a variable from a command prompt | setx |
| Set a variable from PowerShell | [Environment]::SetEnvironmentVariable() |
What environment variables are
Microsoft says user environment variables are set for each user and system environment variables are set for everyone.
PATH is one of them, and it lists the folders Windows searches when you type a program name in a console.
Open the Environment Variables window
- Select Start, type environment properties, and press Enter.
- In System Properties, open the Advanced tab if it is not already showing.
- Select Environment Variables.
Microsoft’s older route is System in Control Panel, then Advanced system settings, then Environment Variables.
User variables and system variables
| Type | Applies to | Admin rights |
|---|---|---|
| User variables | Only your account | Usually not needed |
| System variables | Every account on the PC | Usually needed |
How-To Geek notes that a user variable overrides a system variable when both give the same executable name.
Edit an existing variable
- Select the variable in the User variables or System variables box.
- Select Edit.
- Change the value and select OK.
Add a folder to PATH
- Under User variables, or System variables for every account, double-click Path.
- Select New.
- Type the full folder path, such as C:\Tools.
- Select OK to close the list.
- Select OK again in the Environment Variables and System Properties windows.
To change an entry, select it and edit its text, and you can also delete entries from the same list.
Create a new variable
Select New under User variables or System variables.
Enter a variable name and a value, then select OK in each window.
Check that it worked
Close any Command Prompt or PowerShell window that was open before the change and open a new one.
Microsoft says a process inherits the variables of its parent, so windows opened before the change may not see it.
Windows Central suggests testing a user variable by pressing Windows key + R, typing the name between percent signs such as %myfolder%, and selecting OK.
The Run dialog guide shows the other ways to open that box.
Use PowerToys Environment Variables
- Open PowerToys and select Environment Variables in the left pane.
- Turn on the toggle if it is off.
- Select Launch Environment Variables.
- Use the User or System section to add a variable with a Name and Value, then select Add or Save.
- Use the menu button next to an item to choose Edit or Remove.
Windows Central says to run PowerToys as administrator to change system variables.
The tool also has profiles, so you can switch a group of variables on and off with an Enabled toggle.
Set a variable with setx
Microsoft says setx is the only command-line way to permanently set system environment values.
The older set command changes variables only for the current console window.
| Command | Result |
|---|---|
| setx MYVAR value | Sets a user variable |
| setx MYVAR value /m | Sets a system variable |
Variables set with setx appear only in command windows you open afterwards, not in the current one.
Our guide shows how to open Terminal as administrator.
Do not use setx on a long PATH
Microsoft warns that setx cuts content longer than 1024 characters, and the cropped text is what gets saved.
If that is applied to an existing variable, it can destroy the data that was already stored.
Because PATH is often long, use the Environment Variables window for PATH instead.
Microsoft also says running setx on a variable replaces references like %JAVADIR% with their expanded values.
Set a variable with PowerShell
Changes made with $Env: last only for the current PowerShell session.
To keep a change, Microsoft documents the SetEnvironmentVariable method with a scope.
[Environment]::SetEnvironmentVariable('Foo', 'Bar', 'User')
[Environment]::SetEnvironmentVariable('Foo', 'Bar', 'Machine')
Machine changes need permission and fail with an error without it.
To delete a variable, set it to an empty string, because assigning $null does not remove it.
Our PowerShell version check shows which PowerShell you are running.
Size limit
Microsoft says the maximum size of a user-defined environment variable is 32,767 characters.