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.
-
1
Locate the «This PC» icon on your system. 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
-
3
Click on the «Properties» option. 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.
-
4
Click or double click on «Advanced System Settings». 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.
-
8
View the environment variables. After saving a new variable with path, you can see the entry of variables.
-
9
Click OK. 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 18,524 times.
Is this article up to date?
Environment variables in an operating system are values that contain information about the system environment, and the currently logged in user. They existed in OSes before Windows as well, such as MS-DOS. Applications or services can use the information defined by environment variables to determine various things about the OS, for example, to detect the number of processes, the currently logged in user’s name, the folder path to the current user’s profile or the temporary files directory. Today, we will review a number of methods you can use to create a new user and system environment variable in Windows 10.
Windows 10 has several types of environment variables: user variables, system variables, process variables and volatile variables. User environment variables are accessible to all apps which run in the current user context, system environment variables apply to all users and processes on the PC; process variables are applicable only to a specific process and volatile variables are those which exist only for the current logon session. Most interesting of these are user, system and process variables, as we can modify them.
Example: A user environment variable.
Example: A system environment variable.
Windows 10 stores user environment variables under the following Registry key:
HKEY_CURRENT_USER\Environment
System variables are stored under the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Reference: How to see names and values of environment variables in Windows 10
- Open the classic Control Panel.
- Navigate to Control Panel\User Accounts\User Accounts.
- On the left, click on the Change my environment variables link.
- In the next dialog, click the New button under the User variables for <username> section.
- Enter a variable name you want to create, then enter a variable value you want to assign to it. The dialog allows browsing for a file or folder to save your time.
- Click the OK button, and you are done.
Note: Re-open the required apps (e.g. Command Prompt) to make them read your new environment variable.
Tip: There are a number of other methods you can use to open the environment variables editor in Windows 10. First of all, you can create a special shortcut to open it directly. See Create Environment Variables Shortcut in Windows 10.
Also, there’s a special RunDLL command that you can use (Press Win + R and copy-paste it to the Run box):
rundll32.exe sysdm.cpl,EditEnvironmentVariables
Finally, you can right-click the This PC icon in File Explorer and select Properties from the context menu. Click the «Advanced System Settings» link on the left. In the next dialog, «System Properties», you will see the Environment Variables… button in the bottom of the Advanced tab. Moreover, the Advanced System Settings dialog can be directly opened with the systempropertiesadvanced
command entered into the Run dialog.
Create a User Environment Variable in Command Prompt
- Open a new command prompt
- Type the following command:
setx <variable_name> "<variable_value>"
- Substitute
<variable_name>
with the actual name of the variable you want to create. - Substitute
"<variable_value>"
with the value you want to assign to your variable.
Do not forget to restart your apps (e.g. Command Prompt) to make them read your new environment variable.
The setx command is a console tool that can be used to set or unset user and system environment variables. In the general case, the syntax is as follows:
setx variable_name variable_value
— set an environment variable for the current user.
setx /M variable_name variable_value
— set an environment variable for all user (system-wide).
Type setx /? in a command prompt to see more details about this tool.
Create a User Environment Variable in PowerShell
- Open PowerShell.
- Type the following command:
[Environment]::SetEnvironmentVariable("<variable_name>", "<variable_value>" ,"User")
- Substitute
<variable_name>
with the actual name of the variable you want to create. - Substitute
"<variable_value>"
with the value you want to assign to your variable.
Similarly, you can create a system environment variable.
Create a System Environment Variable
- Open the Run dialog (Win + R), and execute the command
systempropertiesadvanced
. - In the System Properties dialog, switch to the Advanced tab. Click on the Environment Variables… button.
- In the next dialog, click the New button under the System variables section.
- Set the desired name for a variable you want to create, and specify its value, then click OK.
Create a User Environment Variable in Command Prompt
- Open a new command prompt as Administrator.
- Type the following command:
setx /M <variable_name> "<variable_value>"
- Substitute
<variable_name>
with the actual name of the variable you want to create. - Substitute
"<variable_value>"
with the value you want to assign to your variable.
The /M switch makes the setx command create a system variable.
Create a System Environment Variable in PowerShell
- Open PowerShell as Administrator. Tip: You can add «Open PowerShell As Administrator» context menu.
- Type the following command:
[Environment]::SetEnvironmentVariable("<variable_name>", "<variable_value>" ,"Machine")
- Substitute
<variable_name>
with the actual name of the variable you want to create. - Substitute
"<variable_value>"
with the value you want to assign to your variable.
The last parameter of the SetEnvironmentVariable call tells it to register the given variable as a system variable.
That’s it.
Related articles:
- Create Environment Variables Shortcut in Windows 10
- How to see names and values of environment variables in Windows 10
- See names and values of environment variables for a process in Windows 10
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won’t take a lot from you, but it will help us grow. Thanks for your support!
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
- System Variables
- User Variables
- Use of Environment Variables
- Creating User Defined Environment Variables
- Closing Words
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?
If by «system environment variables» you refer specifically to system-wide environment variables, then other answers have already covered this. However, if you want to edit both system-wide and user-specific environment variables then most (if not all) of these answers are inapplicable in general case.
Going through «System» and then “Advanced system settings” -> “Environment Variables” will only work for accounts from Administrators
group, because only such accounts have access to “Advanced system settings”.
If you attempt do that from a regular user account, then trying to access “Advanced system settings” will trigger an UAC prompt asking you for administrator password. If you enter the password, “Advanced system settings” will successfully open, but any user-specific changes you make there will apply to the corresponding administrator’s account (!), not to your original user’s account.
In order to solve this problem (i.e. in order to give regular users the opportunity to edit their own environment variables) Windows provides another way to access the “Environment Variables” dialog.
Open Control Panel. Open User Accounts applet. On the left-hand side of that applet you will see a link that says Change my environment variables. Click that link, and it will take you to the same “Environment Variables” dialog for your user’s environment variables.
If your user has administrator rights, you will be able to edit both sections of that dialog: user-specific environment variables (upper section) and system-wide environment variables (lower section). If you don’t have administrator rights, you will only be able to edit the upper section: your own user-specific environment variables.
This is the proper way to edit environment variables in all post-UAC versions of Windows, not what is suggested in the majority of the answers above.
Unfortunately, Windows 10 November update (version 1511) destroyed this functionality. The Change my environment variables link no longer works. It is there, but it is dead. So for the post-November version of Windows 10 the correct answer is: it is generally impossible to edit user-specific environment variables in version 1511 of Windows 10 from regular user accounts. Microsoft has destroyed Windows 10 with this update and Windows 10 is now unusable. It will remain the case until they fix these ridiculous bugs in 1511 version of the OS.
For the time being one workaround for non-administrative accounts is to, well, add your user account to Administrators
group, logout, log back in, edit the variables using «System» -> “Advanced system settings” method, and then take away administrative rights again…
An alternative workaround is to use PowerShell features as described here
https://technet.microsoft.com/en-us/library/ff730964.aspx
Windows 10 Anniversary Update (version 1607) released August 2, 2016 finally fixed this bug.