Create environment variable windows 10


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. Image titled 1_locate_desktop_screen

    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. 2

    Right-click on the «This PC» icon. This will show a small popup, with few options.

    Advertisement

  3. Image titled 2_click_properties

    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. Image titled 3_click_advanced_settings

    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. Image titled 4_click_environment_variables.png

    5

    Click on Environment Variables. After clicking, it will show a new window dialog called «Environment Variables».

  6. Image titled 5_decide_variables.png

    6

    Decide which variable to add (User / System). Click the New option in any (User/System) section.

  7. Image titled 6_add_variables.png

    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. Image titled 7_view_variables

    8

    View the environment variables. After saving a new variable with path, you can see the entry of variables.

  9. Image titled 8_add_new_vaiable

    9

    Click OK. After clicking OK, you will have successfully created a new User variable with a PATH attached to it.

  10. 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.

Windows 10 User Environment Variable

Example: A system environment variable.

Windows 10 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

  1. Open the classic Control Panel.
  2. Navigate to Control Panel\User Accounts\User Accounts.
  3. On the left, click on the Change my environment variables link.Windows 10 Change My Environment Variables Link
  4. In the next dialog, click the New button under the User variables for <username> section.Windows 10 New User Variable
  5. 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.Windows 10 New User Variable Dialog
  6. Click the OK button, and you are done.Windows 10 New User Variable Is Set

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

  1. Open a new command prompt
  2. Type the following command: setx <variable_name> "<variable_value>"
  3. Substitute <variable_name> with the actual name of the variable you want to create.
  4. Substitute "<variable_value>" with the value you want to assign to your variable.Windows 10 New User Variable Command Prompt 1

Do not forget to restart your apps (e.g. Command Prompt) to make them read your new environment variable.

Windows 10 New User Variable Command Prompt 2

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

  1. Open PowerShell.
  2. Type the following command:
    [Environment]::SetEnvironmentVariable("<variable_name>", "<variable_value>" ,"User")
  3. Substitute <variable_name> with the actual name of the variable you want to create.
  4. Substitute "<variable_value>" with the value you want to assign to your variable.Windows 10 New User Variable PowerShell

Similarly, you can create a system environment variable.

Create a System Environment Variable

  1. Open the Run dialog (Win + R), and execute the command systempropertiesadvanced .
  2. In the System Properties dialog, switch to the Advanced tab. Click on the Environment Variables… button.Windows 10 New System Environment Variable 1
  3. In the next dialog, click the New button under the System variables section.Windows 10 New System Environment Variable 2
  4. Set the desired name for a variable you want to create, and specify its value, then click OK.Windows 10 New System Environment Variable 3

Create a User Environment Variable in Command Prompt

  1. Open a new command prompt as Administrator.
  2. Type the following command: setx /M <variable_name> "<variable_value>"
  3. Substitute <variable_name> with the actual name of the variable you want to create.
  4. Substitute "<variable_value>" with the value you want to assign to your variable.Windows 10 Cmd New System Environment Vairable

The /M switch makes the setx command create a system variable.

Create a System Environment Variable in PowerShell

  1. Open PowerShell as Administrator. Tip: You can add «Open PowerShell As Administrator» context menu.
  2. Type the following command:
    [Environment]::SetEnvironmentVariable("<variable_name>", "<variable_value>" ,"Machine")
  3. Substitute <variable_name> with the actual name of the variable you want to create.
  4. Substitute "<variable_value>" with the value you want to assign to your variable.Windows 10 PowerShell New System Environment Vairable

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.

How To Create Custom Environment Variables in Windows 10 1

Access variable directly from anywhere

Accessing the variable, in this specific example, will automatically open your current user account.

How To Create Custom Environment Variables in Windows 10 2

Quickly access via environmental variable

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:

  1. Type in sysdm.cpl in Run to open System Properties.
    sysdm
  2. From the System Properties window, switch to the Advanced tab and then click Environmental Variables.
    advanced
  3. From the Environmental Variables window, click New under User or System variables (Your choice).
    New
  4. 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.
    ok

A new variable is now added to your environmental variables list.

New variable added

New variable added

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:

cmd 5

Complete path to environmental variable

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.

enter image description here

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.

  • Cr3 кодек для windows 10 скачать
  • Create bootable usb drive windows 10
  • Cr3 canon чем открыть windows 10
  • Create bootable ubuntu usb in windows 10
  • Cr2 codec windows 10 x64