3 Ways to Set Environment Variables on Windows 11

It's easier than you think & more powerful than you know!

Reading time icon 5 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • Environment variables play a crucial role in the proper functioning of your operating system and installed apps.
  • They store information like system paths, temporary file locations, and other user-specific settings.
  • You can use Advanced system settings, Command Prompt, or Windows PowerShell to set it.
  • Continue reading to know the detailed steps for each method.
Environment Variables on Windows 11

Setting environment variables on Windows 11 can help you customize your system, run scripts, and configure applications.

In this guide, we will discuss three ways with step-by-step instructions to do that so you can configure your system according to your preferences.

There are three types of Environment Variables

  • System Environment Variables – The global variables are at the lowest priority, can be accessed by all users & apps on a Windows, and are usually used to define system-wide settings.
  • User Environment Variables – With a higher priority, these only apply to the current user & processes running under that account & are set by the user or apps that run under that account.
  • Process Environment Variables – With the highest priority, they are temporary and apply to the current process & its child processes, providing runtime information or customization for a program.

How do I set & use Environment Variables on Windows 11?

1. Using the Settings app

  1. Press Windows + I to open Settings.
  2. Go to System, then click About.System About - Environment Variables on Windows 11
  3. Click the Advanced system settings link.Advanced system settings - Environment Variables on Windows 11
  4. On the System Properties window, click Environment Variables.Environment Variables window
  5. Next, on the Environment Variables window, you will see two types of variables. Choose an option from either User variables for user or System variables and click New.Add new variable1
  6. On the following window, type in the Variable name without any spaces, and for Variable Value, click the Browse Directory or Browse File button.Add new variable 2
  7. Select the path and click OK.

2. Using the Command Prompt

  1. Press the Windows key, type cmd in the search bar, and click Run as administrator.CMD elevated Environment Variables on Windows 11
  2. To add a temporary variable to your system, use this command after replacing VariableName & Variablevalue with the one you want and hit Enter: set VariableName = VariablevalueSet variable cmd
  3. The set command is used to define an environment variable within the process for which it is defined and will be deleted once the window is closed.
  4. To set environment variables permanently, type the following command after replacing the Variablename with the name of the variable & Value with the value you want to set and press Enter: setx Variablename Value /mSet variable permanent
  5. Now for the path variables, type the following command to list all of them and hit Enter: echo %PATH%
  6. Copy & paste the following command to add another variable to the path directory; replace the PATH value with the path you want to add and press Enter: setx PATH "%PATH%; PATH ValueSet path variable Environment Variables on Windows 11
  7. Refresh the Environment variable window to see the newly added path.

3. Using the Windows PowerShell

  1. Press the Windows key, type powershell, and click Run as administrator.PowerShell - Environment Variables on Windows 11
  2. Type the following command to list of path variables and press Enter: [Environment]::GetEnvironmentVariable(“PATH”)
  3. Copy & paste the following command to declare a path variable after replacing PATH with the path you want to add and hit Enter: $Variable_Name = "PATH"Set variable using PowerShell
  4. To add the variable to the Path Variable list, use this command after replacing Folder PATH with the path you declared and press Enter: [Environment]::SetEnvironmentVariable(“Folder PATH”, “$PATH;$Variable_Name”)
  5. Restart your computer to let the changes take effect.

You can use any of the methods to add a new or missing environment variable to prevent issues like the system could not find the environment option that was entered

How do I edit Environment Variables on Windows 11?

1. Using the Settings app

  1. Press Windows + I to open Settings, then go to System > About >Advanced system settings.
  2. Click Environment Variables, then select the variable you want to edit and click Edit.Edit the enivronment variables on Windows 11
  3. Make the changes and click OK on all three windows to save the changes.Edit the variable
  4. Restart the Environment Variable window to see the changes.

2. Using the Registry Editor

  1. Press Windows + R to open the Run dialog box.Regedit Run command -Environment Variables on Windows 11
  2. Type regedit and click OK to open Registry Editor.
  3. Navigate to this path if you are making changes to User Variables: Computer\HKEY_CURRENT_USER\EnvironmentEdit user variable
  4. For System Variables, go to this path: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\EnvironmentEdit the name and value 1
  5. Once you have located either of the variables, you can change the name by right-clicking and selecting Rename.
  6. To edit the value, double-click the variable, change the Value data, and click OK.Edit the value data - Environment Variables on Windows 11
  7. Restart your computer to save the changes.

3. Using the Windows PowerShell

  1. Open Windows PowerShell with administrator privileges using the same steps mentioned above.
  2. Type the following command to get the current value of the variable after replacing VARIABLENAME with the variable name and press Enter: $Env: VARIABLENAMEPowershell edit value -Environment Variables on Windows 11
  3. Next, to update or edit the value, copy & paste the following command after replacing the VARIABLEANME with the name of the variable & NEWVALUE with the value that you want to add, then hit Enter: $Env: VARIABLENAME = "NEWVALUE"
  4. Reboot your PC to save the changes.

How do I get a list of Environment Variables in Windows?

To get a list of environment variables in Windows 11, you can open Command Prompt with administrator rights and type set, and hit Enter.

 list of environment variables in Windows 11 CMD

In Powershell, with admin privileges to get a list of environment variables, copy & paste the following command and hit Enter: [System.Environment]::GetEnvironmentVariables()

 list of environment variables in Windows 11 Powershell

If you want to print the environment variables list you got on PowerShell to apply the same settings on another computer, read this guide.

Where are Windows environment variables stored?

You can find the environment variables in Registry Editor. The system variables are found in Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, wherein the user variables are located at Computer\HKEY_CURRENT_USER\Environment

Setting environment variables on Windows 11 can help you customize your system settings; however, you must always exercise caution when making changes to system variables.

Remember to double-check the variable name & value, and always create a backup of your registry editor before making changes.

Stuck somewhere? Don’t hesitate to mention your queries in the comments section below. We will be happy to assist you.

More about the topics: Windows 11