How to Edit User and System Environment Variables in Windows
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. The variables can be used both in scripts and on the command line. Environment variables makes it easy when certain standard directories and parameters need to be referenced but where the actual locations or names can vary from computer to computer.
The variable (ex: "%UserProfile%") is used as a type of shortcut of the value (ex: "C:\Users\<username>").
There are two types of environment variables: user environment variables (set only for current user) and system environment variables (set for all users).
This tutorial will show you how to edit user and system environment variables in Windows 7, Windows 8, and Windows 10.
Contents
- Option One: Edit User Environment Variables in Environment Variables
- Option Two: Edit User Environment Variables in Command Prompt
- Option Three: Edit User Environment Variables in PowerShell
- Option Four: Edit User Environment Variables in Registry Editor
- Option Five: Edit System Environment Variables in Environment Variables
- Option Six: Edit System Environment Variables in Command Prompt
- Option Seven: Edit System Environment Variables in PowerShell
- Option Eight: Edit System Environment Variables in Registry Editor
1 Open the Control Panel (icons view), and click/tap on the User Accounts icon.
2 Click/tap on the Change my environment variables link on the left side, and close the User Accounts control panel window if you like. (see screenshot below)
3 Select a variable you want to edit listed in the top User variables for <current user name> section, and click/tap on the Edit button. (see screenshot below)
4 Make any changes you want to the variable name and variable value, and click/tap on OK. (see screenshot below)
If you like, you could click/tap on the Browse Directory button to navigate to and select a directory to have its path entered for the variable value.
If you like, you could click/tap on the Browse File button to navigate to and select a file to have its path entered for the variable value.
5 When finished editing user variables, click/tap on OK to apply. (see screenshot below)
1 Open a command prompt.
2 Type theset
command into the command prompt, press Enter, and make note of the user variable name (ex: "Downloads") you want to edit the value for. (see screenshot below)
3 Type the command below into the command prompt, and press Enter. (see screenshot below)
setx [variable name] "[variable value]"
Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you wanted to edit from step 2.
Substitute [variable value] in the command above with the edited variable value (ex: "C:\Users\Brink\Downloads") you want.
4 You can now close the command prompt if you like.
1 Open Windows PowerShell.
3 Copy and paste theGet-ChildItem Env:
command into PowerShell, press Enter, and make note of the user variable name (ex: "Downloads") you want edit the value for. (see screenshot below)
3 Type the command below into PowerShell, and press Enter. (see screenshot below)
[Environment]::SetEnvironmentVariable("[variable name]","[variable value]","User")
Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you wanted to edit from step 2.
Substitute [variable value] in the command above with the edited variable value (ex: "C:\Users\Brink\Downloads") you want.
4 You can now close Windows PowerShell if you like.
1 Press Win + R keys to open Run, type regedit into Run, and click/tap on OK to open Registry Editor.
2 Navigate to the key below in the left pane of Registry Editor. (see screenshot below)
HKEY_CURRENT_USER\Environment
3 If you want to edit a variable name, then:
A) In the right pane of the Environment key in Registry Editor, right click or press and hold on the value name (ex: "Downloads") of the variable you want to edit for your account, and click/tap on Rename. (see screenshot below)
B) Type a new variable name you want to use, and press Enter. (see screenshot below)
4 If you want to edit a variable value, then:
A) In the right pane of the Environment key in Registry Editor, double click/tap on the name (ex: "Downloads") of the variable name you want to edit the value data for. (see screenshot below step 2)
B) Type a new variable value you want to use, and click/tap on OK. (see screenshot below)
5 When finished editing user variables for your account, you can close Registry Editor if you like.
You must be signed in as an administrator to do this option.
1 Open the Control Panel (icons view), and click/tap on the System icon.
Starting with Windows 10 build 20161, you will need to open Settings instead, click/tap on the System icon, and click/tap on About on the left side.
2 Click/tap on the Advanced system settings link on the left side, and close the System control panel window if you like. (see screenshot below)
3 Click/tap on the Environment Variables button. (see screenshot below)
4 Select a variable you want to edit listed in the bottom System variables section, and click/tap on the Edit button. (see screenshot below)
5 Make any changes you want to the variable name and variable value, and click/tap on OK. (see screenshot below)
If you like, you could click/tap on the Browse Directory button to navigate to and select a directory to have its path entered for the variable value.
If you like, you could click/tap on the Browse File button to navigate to and select a file to have its path entered for the variable value.
6 When finished editing system variables, click/tap on OK to apply. (see screenshot below)
7 Click/tap on OK. (see screenshot below)
You must be signed in as an administrator to do this option.
1 Open an elevated command prompt.
2 Type theset
command into the elevated command prompt, press Enter, and make note of the system variable name (ex: "Downloads") you want to edit the value for. (see screenshot below)
3 Type the command below into the elevated command prompt, and press Enter. (see screenshot below)
setx [variable name] "[variable value]" -M
Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you wanted to edit from step 2.
Substitute [variable value] in the command above with the edited variable value (ex: "%UserProfile%\Downloads") you want.
4 You can now close the elevated command prompt if you like.
You must be signed in as an administrator to do this option.
1 Open an elevated Windows PowerShell.
2 Copy and paste theGet-ChildItem Env:
command into PowerShell, press Enter, and make note of the system variable name (ex: "Downloads") you want edit the value for. (see screenshot below)
3 Type the command below into the elevated PowerShell, and press Enter. (see screenshot below)
[Environment]::SetEnvironmentVariable("[variable name]","[variable value]","Machine")
Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you wanted to edit from step 2.
Substitute [variable value] in the command above with the edited variable value (ex: "%UserProfile%\Downloads") you want.
4 You can now close the elevated Windows PowerShell if you like.
1 Press Win + R keys to open Run, type regedit into Run, and click/tap on OK to open Registry Editor.
2 Navigate to the key below in the left pane of Registry Editor. (see screenshot below)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
3 If you want to edit a variable name, then:
A) In the right pane of the Environment key in Registry Editor, right click or press and hold on the value name (ex: "Downloads") of the variable you want to edit, and click/tap on Rename. (see screenshot below)
B) Type a new variable name you want to use, and press Enter. (see screenshot below)
4 If you want to edit a variable value, then:
A) In the right pane of the Environment key in Registry Editor, double click/tap on the name (ex: "Downloads") of the variable name you want to edit the value data for. (see screenshot below step 2)
B) Type a new variable value you want to use, and click/tap on OK. (see screenshot below)
5 When finished editing system variables, you can close Registry Editor if you like.
That's it,
Shawn
Related Tutorials
- Complete List of Environment Variables in Windows 10
- How to Create Environment Variables Shortcut in Windows
- How to Set New User and System Environment Variables in Windows
- How to Delete User and System Environment Variables in Windows
- How to Add Environment Variables Context Menu in Windows 10