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






OPTION ONE

Edit User Environment Variables in Environment Variables


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)

Edit User and System Environment Variables in Windows-environment_variables-1.jpg

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)

Edit User and System Environment Variables in Windows-edit_user_environment_variables-1.png

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.

Edit User and System Environment Variables in Windows-edit_user_environment_variables-2.png

5 When finished editing user variables, click/tap on OK to apply. (see screenshot below)

Edit User and System Environment Variables in Windows-environment_variables-4.png






OPTION TWO

Edit User Environment Variables in Command Prompt


1 Open a command prompt.

2 Type the set 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)

Edit User and System Environment Variables in Windows-edit_user_environment_variables-command.jpg

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.

Edit User and System Environment Variables in Windows-system_environment_variables-command.png






OPTION THREE

Edit User Environment Variables in PowerShell


1 Open Windows PowerShell.

3 Copy and paste the Get-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)

Edit User and System Environment Variables in Windows-edit_user_environment_variables_powershell.jpg

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.

Edit User and System Environment Variables in Windows-user_environment_variables-powershell.png






OPTION FOUR

Edit User Environment Variables in Registry Editor


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

Edit User and System Environment Variables in Windows-edit_user_environment_variables_regedit-1.jpg

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)

Edit User and System Environment Variables in Windows-edit_user_environment_variables_regedit-2.jpg

B) Type a new variable name you want to use, and press Enter. (see screenshot below)

Edit User and System Environment Variables in Windows-edit_user_environment_variables_regedit-3.jpg

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)

Edit User and System Environment Variables in Windows-edit_user_environment_variables_regedit-4.png

5 When finished editing user variables for your account, you can close Registry Editor if you like.






OPTION FIVE

Edit System Environment Variables in Environment Variables


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)

Edit User and System Environment Variables in Windows-environment_variables-2.jpg

3 Click/tap on the Environment Variables button. (see screenshot below)

Edit User and System Environment Variables in Windows-environment_variables-3.png

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)

Edit User and System Environment Variables in Windows-edit_system_environment_variables-1.png

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.

Edit User and System Environment Variables in Windows-edit_system_environment_variables-2.png

6 When finished editing system variables, click/tap on OK to apply. (see screenshot below)

Edit User and System Environment Variables in Windows-environment_variables-4.png

7 Click/tap on OK. (see screenshot below)

Edit User and System Environment Variables in Windows-environment_variables-5.png






OPTION SIX

Edit System Environment Variables in Command Prompt


You must be signed in as an administrator to do this option.


1 Open an elevated command prompt.

2 Type the set 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)

Edit User and System Environment Variables in Windows-edit_system_environment_variables-command.jpg

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.

Edit User and System Environment Variables in Windows-system_environment_variables-command.png






OPTION SEVEN

Edit System Environment Variables in PowerShell


You must be signed in as an administrator to do this option.


1 Open an elevated Windows PowerShell.

2 Copy and paste the Get-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)

Edit User and System Environment Variables in Windows-edit_system_environment_variables_powershell.jpg

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.

Edit User and System Environment Variables in Windows-system_environment_variables-powershell.png






OPTION EIGHT

Edit System Environment Variables in Registry Editor


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

Edit User and System Environment Variables in Windows-edit_system_environment_variables_regedit-1.jpg

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)

Edit User and System Environment Variables in Windows-edit_system_environment_variables_regedit-2.jpg

B) Type a new variable name you want to use, and press Enter. (see screenshot below)

Edit User and System Environment Variables in Windows-edit_system_environment_variables_regedit-3.jpg

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)

Edit User and System Environment Variables in Windows-edit_system_environment_variables_regedit-4.png

5 When finished editing system variables, you can close Registry Editor if you like.


That's it,
Shawn