Download Article
Download Article
This wikiHow teaches how to add new environment variables in Windows 10. Environment variables are useful to specify paths internally in the OS for specific programs. It is basically stored in the form of a name and value pair. OS has a lot of builtin environment variables like ‘PATH’ where paths to installed Softwares are stored. Stick to this article, to find out how to add environment variables in Windows 10.
-
You may find it on your desktop screen. You can go to your desktop by pressing Ctrl+D.
-
2
Right-click on the «This PC» icon. This will show a small popup, with few options.
Advertisement
-
You may find this in the last position below the «Rename» option. This will open a new window with all the system details like RAM, Processor, OS, etc.
-
You may find this option on the left-hand side of the newly opened window (System Details). This option is below the «System Protection» option.
-
5
Click on Environment Variables. After clicking, it will show a new window dialog called «Environment Variables».
-
6
Decide which variable to add (User / System). Click the New option in any (User/System) section.
-
7
Add the variable name and variable value and click OK. In variable_name, you can give a name to your user variable and specify PATH in the variable_value, finally, click «ok» to save the changes.
-
After saving a new variable with path, you can see the entry of variables.
-
After clicking OK, you will have successfully created a new User variable with a PATH attached to it.
Advertisement
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Thanks for submitting a tip for review!
About This Article
Thanks to all authors for creating a page that has been read 26,133 times.
Is this article up to date?
Environmental Variables are dynamic objects which define different elements in a Windows environment. These variables can be used by different programs from anywhere within Windows and provide certain parameters to perform specific tasks.
Creating custom environment variables in Windows assists you in the longer run, as it enables you to run a program or a .exe file from any directory in Windows, and the title of the program would still be recognizable.
If you are using the same path or directory over and over again, it would be better to create a variable and provide a path of your directory and just use that variable instead of having to give complete paths each time.
You can say these variables as shortcuts to your apps. This can make you move around in Windows rather quickly. Before we dig into the process of creating a custom environmental variable, let us briefly discuss a bit about them.
Table of Contents
Types of Variables
There are two types of environment variables: A system variable and a user variable. Both are combined to make a complete computer environment.
System Variables
System variables are termed global variables and can be accessed or used by any user account on your computer.
User Variables
User variables are termed specific variables, which can only be accessed within the same user account. Other accounts on your computer are not familiar with such variables.
Use of Environment Variables
If you have to go to User Profile, and you have created a system variable with the name “userprofile”. You don’t need to open File Explorer and then navigate to your profile. Just simply access the variable you have created by typing “%userprofile%” into the Start Menu.
Accessing the variable, in this specific example, will automatically open your current user account.
Another example of using an environmental variable is while using a .exe file in the Command Prompt. If you have placed a .exe file in the “Downloads” folder, then you will need to provide the path “%userprofile%\Downloads\ABC.exe” each time to use the file. However, if it is declared as a user or system variable, then simply putting in “ABC.exe” will automatically fetch the .exe file, regardless of your current directory in the Command Prompt.
Now you know how these variables are helpful. Let us now show you how you can create your own custom variables and assign a path to save your time and navigate quickly within your OS.
Creating User Defined Environment Variables
Let’s create our own environment variables. Follow the steps below to do so:
- Type in sysdm.cpl in Run to open System Properties.
- From the System Properties window, switch to the Advanced tab and then click Environmental Variables.
- From the Environmental Variables window, click New under User or System variables (Your choice).
- In the New Variable popup, enter a name for your variable and then enter its complete path in Variable Value. Click Ok when done. In our case, we want to access the “Company” folder so we put the address of that particular folder in “Variable Value” of the new variable.
A new variable is now added to your environmental variables list.
Now typing in the name of your environmental variable in Run or Command Prompt will automatically open the desired location.
You can also create environmental variables for .exe files, batch files, etc., and use them to pass parameters and perform certain tasks.
If you wish to know the path for a variable, open the Command Prompt and type “echo” followed by the environmental variable inside percentage (%) signs, as in the following example:
In case you do not wish to use a variable in the future or want to edit it, you can delete the variable by selecting it in the Environmental variables window and then clicking Delete, or you may also click Edit to change its path or name.
Closing Words
Creating your own customized variables can be super helpful in cases where you have to use a path over and over again. What methods do you use as shortcuts for opening your favorite programs and folders?
Environment variables are key-value pairs a system uses to set up a software environment. The environment variables also play a crucial role in certain installations, such as installing Java on your PC or Raspberry Pi.
In this tutorial, we will cover different ways you can set, list, and unset environment variables in Windows 10.
Prerequisites
- A system running Windows 10
- User account with admin privileges
- Access to the Command Prompt or Windows PowerShell
Check Current Environment Variables
The method for checking current environment variables depends on whether you are using the Command Prompt or Windows PowerShell:
List All Environment Variables
In the Command Prompt, use the following command to list all environment variables:
set
If you are using Windows PowerShell, list all the environment variables with:
Get-ChildItem Env:
Check A Specific Environment Variable
Both the Command Prompt and PowerShell use the echo command to list specific environment variables.
The Command prompt uses the following syntax:
echo %[variable_name]%
In Windows PowerShell, use:
echo $Env:[variable_name]
Here, [variable_name]
is the name of the environment variable you want to check.
Set Environment Variable in Windows via GUI
Follow the steps to set environment variables using the Windows GUI:
1. Press Windows + R to open the Windows Run prompt.
2. Type in sysdm.cpl and click OK.
3. Open the Advanced tab and click on the Environment Variables button in the System Properties window.
4. The Environment Variables window is divided into two sections. The sections display user-specific and system-wide environment variables. To add a variable, click the New… button under the appropriate section.
5. Enter the variable name and value in the New User Variable prompt and click OK.
Set Environment Variable in Windows via Command Prompt
Use the setx
command to set a new user-specific environment variable via the Command Prompt:
setx [variable_name] "[variable_value]"
Where:
[variable_name]
: The name of the environment variable you want to set.[variable_value]
: The value you want to assign to the new environment variable.
For instance:
setx Test_variable "Variable value"
Note: You need to restart the Command Prompt for the changes to take effect.
To add a system-wide environment variable, open the Command Prompt as administrator and use:
setx [variable_name] "[variable_value]" /M
Unset Environment Variables
There are two ways to unset environment variables in Windows:
Unset Environment Variables in Windows via GUI
To unset an environment variable using the GUI, follow the steps in the section on setting environment variables via GUI to reach the Environment Variables window.
In this window:
1. Locate the variable you want to unset in the appropriate section.
2. Click the variable to highlight it.
3. Click the Delete button to unset it.
Unset Environment Variables in Windows via Registry
When you add an environment variable in Windows, the key-value pair is saved in the registry. The default registry folders for environment variables are:
- user-specific variables: HKEY_CURRENT_USEREnvironment
- system-wide variables: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
Using the reg
command allows you to review and unset environment variables directly in the registry.
Note: The reg
command works the same in the Command Prompt and Windows PowerShell.
Use the following command to list all user-specific environment variables:
reg query HKEY_CURRENT_USEREnvironment
List all the system environment variables with:
reg query "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment"
If you want to list a specific variable, use:
reg query HKEY_CURRENT_USEREnvironment /v [variable_name]
or
reg query "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment" /v [variable_name]
Where:
/v
: Declares the intent to list a specific variable.[variable_name]
: The name of the environment variable you want to list.
Use the following command to unset an environment variable in the registry:
reg delete HKEY_CURRENT_USEREnvironment /v [variable_name] /f
or
reg delete "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment" /v [variable_name] /f
Note: The /f
parameter is used to confirm the reg delete
command. Without it, entering the command triggers the Delete the registry value EXAMPLE (Yes/No)?
prompt.
Run the setx
command again to propagate the environment variables and confirm the changes to the registry.
Note: If you don’t have any other variables to add with the setx
command, set a throwaway variable. For example:
setx [variable_name] trash
Conclusion
After following this guide, you should know how to set user-specific and system-wide environment variables in Windows 10.
Looking for this tutorial for a different OS? Check out our guides on How to Set Environment Variables in Linux, How to Set Environment Variables in ZSH, and How to Set Environment Variables in MacOS.
Was this article helpful?
YesNo
Environment variables are user variables or Windows system variables that describe the environment in which apps run. They can tell your apps things like the name of the computer, the name of the user account, the current working directory, etc. Do you want to know more about how to use environment user variables and Windows system variables? If you do, read this tutorial and learn how to create environment variables in Windows 11 and Windows 10. There are some situations when knowing how to do that can prove very useful.
Things you should know before creating environment variables in Windows
There are two things you should know before following any of the steps shown in this guide to create user and system variables pointing to a folder, file, or anything else. The first and the most important one is to understand what environment variables are. Secondly, you should know the differences in user variables vs. system variables in order to be able to decide what kind of variable you should create. For answers and explanations on these matters, I recommend you read this article before going ahead with the instructions below: What are environment variables in Windows?.
Environment user and system variables in Windows
Then, once you understand what environment variables are and once you know what type of variable you want to create, you’ll have to open the Environment Variables window. If you’ve read the tutorial I recommended in the previous paragraph, you already know how to do it. However, if you didn’t have time for that, know that an easy method of launching the Environment Variables is to use the search.
If you’re using Windows 11, click or tap the search box (or button) on your taskbar, type environment, and click or tap the “Edit the system environment variables” result.
How to open the Environment Variables in Windows 11
The same applies to Windows 10. Click or tap on the search box on the taskbar, enter environment in the search box, and select “Edit the system environment variables” in the list of results.
How to open the Environment Variables in Windows 10
Then, the steps to create user variables or system variables are the same regardless of the operating system you’re using. As you can see in the next picture, even the Environment Variables window is identical in Windows 11 and Windows 10.
Environment Variables in Windows 11 vs Windows 10
Without further ado, here are the steps to create environment user variables and system variables in Windows:
How to create environment user variables in Windows
User environment variables are available only to your user account. When creating such variables, their values should include paths towards locations that are accessible to your user account. For example, you can’t have your user variable point to a personal folder of another user account (like Documents, Pictures, Music, etc.). In the “User variables for [user account]” section, click or tap New.
The Environment Variables window
The “New User Variable” window opens. Start by typing the name of the variable you want to create (1). Make it something suggestive to easily remember its purpose. Then, type its value (2). The value may include a path or more. A path can point to a folder or a file. You can also use other existing variables to build up the path you want. For example, if you want the variable to point to the folder used by Steam to save your games, you can set its value like this:
%programfiles(x86)%\Steam\steamapps\common
Entering the name and value of a new user variable
TIP: If you want your environment user variable to have more than one value, separate its values with semicolons (;) — for example, Path 1; Path 2; Path 3. Oh, and it’s not mandatory to use only paths to folders and files as values for user variables. Depending on what you want to do with the variable you create, you can also store strings (text) as its value.
When you are done setting the user variable, click or tap OK. The new variable is added to the list of user variables, but it is not yet created, so you can’t use it at this time.
The new user variable has been added to the list
To create the new user variable, click or tap OK in the Environment Variables window.
Saving the new user variable in Windows
To test if the user variable was created successfully and that it points to what you want, open a Run window (Windows + R). Type the name of the environment variable you just created between percent (%) signs. For example, to execute the steamgames variable that I just created, I have to type:
%steamgames%
Then, click or tap on OK. In my case, this action opens the folder that contains all the games I have downloaded and installed from my Steam account.
Checking a user variable in Windows
IMPORTANT: Any user can add, change, or delete user environment variables. User variables can be created by Windows 11 or Windows 10, apps, and users alike.
How to create Windows system variables
The process for creating system variables is the same as for creating user variables. To make sure you get it right, I’ll go through another quick example.
In the System variables section from the Environment Variables window, click or tap New.
Starting the process of creating a new Windows system variable
The New System Variable window opens. Enter the variable’s name (1) and value (2). In the next screenshot, for instance, you can see that I chose to create a new system variable called games that points to a folder called Games on my C: drive.
Entering the name and value of a New System Variable
TIP: Note that you can add multiple values to a variable — all you need to do is separate them with semicolons (;). Also, keep in mind that if you specify a path as a value for a system variable, that path should be accessible to all user accounts. If that path points to a location where only one user account has access, you should create a user variable instead of a system variable.
When you are done customizing the new system variable, click or tap OK. The new variable is added to the list of system variables, but it is not yet created.
The Windows system variable has been added to the list
In the Environment Variables window, click or tap OK to create the new environment variable.
Saving a new Windows system variable
To test if the system variable was created successfully, open Run (Windows + R) and insert the name of the environment system variable you created between percent (%) signs. For example, to run the games variable that I created, I must type:
%games%
Then, press the OK button.
Verifying a Windows system variable
In my case, Windows opened the Games folder where I keep most of my games. All users have access to this folder, and they can use this variable to access those games quickly.
IMPORTANT: Are you wondering whether any user can add system environment variables or change existing ones’ values? The answer is NO! Only administrators can perform these actions. Standard users don’t have enough clearance to make or change Windows system variables because they affect every user and every app on the PC. If you’re using Windows 11, this tutorial provides more details about standard and administrator accounts: How to change the Administrator account on Windows 11. And, if you have Windows 10, read this guide instead: 6 ways to change an account to Administrator and back in Windows 10.
What user variables or Windows system variables did you create?
The process involved in creating environment variables in Windows is not that complicated. Furthermore, it’s the same in Windows 11 and Windows 10. However, before you get the hang of it, you should first experiment by making a couple of safe user variables that don’t negatively impact the system’s proper operation. If you have questions about environment variables or if you have something to add to this guide, don’t hesitate to leave me a comment. Also, if you want to receive news whenever we publish new articles, do subscribe to our newsletter using the form below.
This article explains how to set up environment variables in Windows 11.
Environment variables are a powerful feature in Windows systems. Various processes and applications use them to determine operational behaviors based on specific system-wide or user-specific settings.
They store configuration data and system state information that can be accessed by different software applications and services running on a Windows system.
You can customize your System’s behavior for different applications and tasks by setting up environment variables. For example, you can set a variable to specify the path to a specific tool or define a variable that controls the behavior of a specific application.
In Windows 11, environment variables can be created through System Properties, the Command Prompt, or PowerShell.
Using System Properties
To create an environment variable using System Properties, follow these steps:
Right-click the Start button and select System on the Power User menu.
Next, click the Advanced system settings link under “Related settings” on the right.
This will open the System Properties window with the Advanced tab selected. Click the Environment Variables… button at the bottom of the System Properties window.
To create a user-specific variable, under the “User variables for [Your Username]” section, click the New… button.
To create a system-wide variable (accessible to all users), under the “System variables” section, click the New… button.
In the New System Variable or New User Variable window, enter the variable’s Name and its Value.
Create User Variable:
Under the User variables for the [Username] section, click New. Then, type in the Variable name and Variable value.
Click OK to close the new variable window.
Create System Variable:
Under the System Variables section, click the New button. Then, enter the Variable name and Variable value.
Click OK again to close the Environment Variables window.
You might need to restart your System or log out and back in for some changes.
Using the Command Prompt
You can also create environment variables via Command Prompt.
First, open the Windows Terminal app as administrator. You can also right-click the Start button and select Windows Terminal (Admin).
In the Windows Terminal, open a Command Prompt tab by clicking the down arrow icon next to the new tab button and selecting Command Prompt.
Create User Variable
Type the command
setx VARIABLE_NAME "VARIABLE_VALUE"
Replace VARIABLE_NAME
with the name you wish to assign to the variable and VARIABLE_VALUE
with the actual value.
Example:
setx Downloads "C:\Users\rworl\Downloads"
Create System Variable:
Type the command
setx /M VARIABLE_NAME "VARIABLE_VALUE"
Replace VARIABLE_NAME
with the name you wish to assign to the variable and VARIABLE_VALUE
with the actual value.
Example:
setx /M Downloads "C:\Users\rworl\Downloads"
Using Windows PowerShell
You can create environment variables using Windows PowerShell.
First, open the Windows Terminal app as administrator. Right-click the Start button and select Windows Terminal (Admin) on the Power User menu.
In the Windows Terminal, open a PowerShell tab if it’s not already open by default.
Create a User Variable
For a user-specific variable, replace Machine
with User
:
[System.Environment]::SetEnvironmentVariable('VARIABLE_NAME', 'VARIABLE_VALUE', [System.EnvironmentVariableTarget]::User)
.
Example:
[Environment]::SetEnvironmentVariable("Downloads","C:\Users\Richard\Downloads","User")
Create a System Variable
Type the command
[System.Environment]::SetEnvironmentVariable('VARIABLE_NAME', 'VARIABLE_VALUE', [System.EnvironmentVariableTarget]::Machine)
Example:
[Environment]::SetEnvironmentVariable("Downloads","%UserProfile%\Downloads","Machine")
After using the command line methods, the environment variable is immediately available in new Command Prompt or PowerShe instances.
However, you may still need to restart applications or the System to see the changes everywhere.
Verifying the Creation of the Variable
To confirm that your environment variable has been set, you can use the Command Prompt or PowerShell to echo its value:
- In Command Prompt:
echo %VARIABLE_NAME%
- In PowerShell:
$env:VARIABLE_NAME
If the environment variable has been successfully created, the commands above should display its value.
That should do it!
Conclusion:
- Environment variables in Windows 11 are a powerful feature that can be used to store configuration data and system state information.
- Users can customize system behavior for applications and tasks by setting up environment variables.
- This article provides detailed steps for creating environment variables using System Properties, Command Prompt, and Windows PowerShell in Windows 11.
- After creating environment variables, users can verify their successful creation using Command Prompt or PowerShell.
- Feel free to leave a comment if you have any feedback or additional information to share regarding this guide.