How To Set Environment Variables in Windows 11

Windows uses environment variables to store information about a system, such as its processes and resource usage. Setting these variables means creating shortcuts that allow you to find data locations using a keyword instead of typing in the whole location path. If you want to avoid manually remembering and entering file locations, we’ve got you covered. In this tutorial, we will look at how to create environment variables.

How To Set Environment Variables in Windows 11

What You Need to Know About Environment Variables

The environment variable is a variable that the computer automatically creates and maintains. It helps the system locate and install applications, check system preferences, and execute commands. You can access it from anywhere on your device.

There are two types of variables: the system and the user variables. The former is a global variable that every user on the system can access. In contrast, a user variable is only accessible to the person currently logged into the computer. This prevents the system from automatically creating and maintaining the same environment variable for everyone.

Information about your account’s location, such as the location of temporary files, is stored under user variables. The logged-in user account can modify these variables, but other accounts cannot. The Windows operating system also has system environment variables that contain drivers and other programs necessary for system operations. You cannot alter these variables in the same way you can change user variables. Let’s check out the different methods of creating environment variables.

Setting Environment Variables in Windows 11

You can take several steps to create environment variables in Windows 11. You will then be able to make and maintain shortcuts that allow you to use the system more efficiently. This is how to set environment variables in Windows 11.

  1. Tap Win + I to access the Settings menu.
  2. Scroll to the bottom of the page and click “About.”
  3. Navigate to “Device Specifications” and press “Advanced System Settings.”
  4. In the “System Properties” dialogue box, hit “Environmental Variables.”
  5. Pick either the “System” or “User” environmental variable and tap the “New” button located next to your selected section.
  6. Assign the new variable a name, ensuring that there are no spaces.
  7. Head to the “Variable Value” section to assign the variable the desired location. You can do this by clicking the “Browse Directory” or the “Browse File” buttons and searching the list displayed.
  8. Click “OK” once the variable name and value have been created.

You have successfully set an environment variable.

How to Use the New Environment Variable

You can access the environment variable you have created from different locations. Let’s look at how you can use your variable.

Command Prompt Method

  1. Open the Start menu and enter CMD in the search box.
  2. In Command Prompt, type in the following command, filling in your variable name where it says “variablename.”

echo %variablename%

You will now have accessed your new variable using the Command Prompt.

PowerShell Window Method

  1. Go to the Start menu and type in “PowerShell” to open the window.
  2. Type in the command that follows, replacing “variable” with the name of your new variable.

Write-Output $env.variable

You have now opened the new variable using the PowerShell Window method.

Start Menu Method

Head to the Start menu and enter the command shown here, replacing “variable” with the name of your new variable.

%variable%

You have now accessed your new variable using the Start menu.

Changing Environment Variables

You can edit your environment variables to make them easier to use and access. Here’s how to change these variables in Windows.

  1. Open the Start menu and type “edit ENV” into the search bar.
  2. Tap “Edit environment variables for your account.”
  3. Choose the variable you would like to change and press “Edit.”
  4. In the “Edit Environment Variable” panel that opens, modify your variable accordingly.
  5. Click “OK” to complete the process.
  6. You can also delete the variable by selecting it and tapping “Delete.”

How to Set or Edit a Variable Permanently

Setting a variable permanently will make it available to all Windows users. Check out how to make these variable changes.

  1. Go to the Start menu and open “Control Panel.”
  2. Tap “System and Security” then “System” and lastly “Advanced System Settings.”
  3. Select “Environment Variables” then “System Variables.”
  4. To add the new permanent variable, tap “New” and enter the name.
  5. To fill in the “variable value” slot, hit “Browse Directory” and pick a location from the list displayed.
  6. To edit the permanent variable, go to “System Variables,” click “Edit,” and enter the variable’s name.
  7. Tap “Browse Directory” to retrieve the directory you would like to edit.

You have now set a permanent variable for the system. For the new changes to take effect, you will need to go to RE-START CMD.

Setting Environment Variables from the Command Prompt

If you would like to use terminal to set up environment variables, this is how to go about it.

  1. Open Run by tapping Win + R.
  2. In the dialogue box that opens, type in wt.exe.
  3. Press “OK” to open Windows Terminal.
  4. Assign names to the variable by typing in the following command, where “variablename” will be replaced by the name of your new variable.

$ export VAR=variablename

If you would like spaces in your name, you should enclose the name in double-quotes as shown below.

$ export VAR=“variable name”

The $ sign needs to precede the environment variable for the name to be displayed. For example:

$ echo $ VAR

You could also use the “printenv” command to show the variable name as follows:

printenv VAR

You have now set up an environment variable in terminal.

Set Windows PATH Variable

The PATH variable is a list of the programs and commands stored on your computer. You must enter the program’s address or command that you want to launch to open it. When you run a command, Windows checks for the address of the program or command in the current directory. If it can’t find it, it looks for it in the PATH variable. Check out how to set a PATH variable.

  1. Open the Start menu and type “edit ENV” into the search bar.
  2. Tap “Edit Environment variables for your account.”
  3. Press “Environment variables” in the “System Variables” section, then click “Edit.”
  4. In the window that opens, hit “Variable value” and input the path you would like to add.
  5. Tap “OK” to complete the process.

You have now set up a PATH variable, and you will need to restart your device for these changes to reflect in your system. If you use this method, the PATH variable will differ for each system user. For the changes to be applied to everyone who uses the computer, you will have to alter the System Variables.

FAQs

Can I add more than one value to the same environment variable?

Yes, assigning more than one value to the same environment variable is possible. To do this, open the variable and click the “Edit” button. Tap the “New” button to input the additional value.

Manage Your System With Ease

Setting environment variables in Windows makes it easy to locate essential files stored on your computer. Creating and managing these variables can be a little confusing at first, but you will soon get the hang of it with this guide. You will now be able to quickly access your important documents using a shortcut instead of typing in a long file location.

Have you set environment variables in Windows? What method did you use? Kindly let us know in the comments below.

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.