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.
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.
- Tap Win + I to access the Settings menu.
- Scroll to the bottom of the page and click “About.”
- Navigate to “Device Specifications” and press “Advanced System Settings.”
- In the “System Properties” dialogue box, hit “Environmental Variables.”
- Pick either the “System” or “User” environmental variable and tap the “New” button located next to your selected section.
- Assign the new variable a name, ensuring that there are no spaces.
- 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.
- 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
- Open the Start menu and enter CMD in the search box.
- In Command Prompt, type in the following command, filling in your variable name where it says “variablename.”
You will now have accessed your new variable using the Command Prompt.
PowerShell Window Method
- Go to the Start menu and type in “PowerShell” to open the window.
- Type in the command that follows, replacing “variable” with the name of your new 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.
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.
- Open the Start menu and type “
edit ENV” into the search bar.
- Tap “Edit environment variables for your account.”
- Choose the variable you would like to change and press “Edit.”
- In the “Edit Environment Variable” panel that opens, modify your variable accordingly.
- Click “OK” to complete the process.
- 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.
- Go to the Start menu and open “Control Panel.”
- Tap “System and Security” then “System” and lastly “Advanced System Settings.”
- Select “Environment Variables” then “System Variables.”
- To add the new permanent variable, tap “New” and enter the name.
- To fill in the “variable value” slot, hit “Browse Directory” and pick a location from the list displayed.
- To edit the permanent variable, go to “System Variables,” click “Edit,” and enter the variable’s name.
- 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.
- Open Run by tapping Win + R.
- In the dialogue box that opens, type in wt.exe.
- Press “OK” to open Windows Terminal.
- 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:
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.
- Open the Start menu and type “
edit ENV” into the search bar.
- Tap “Edit Environment variables for your account.”
- Press “Environment variables” in the “System Variables” section, then click “Edit.”
- In the window that opens, hit “Variable value” and input the path you would like to add.
- 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.
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.