Environment variables is not a new term in context to Windows 10. People have known them for years, as they are available in Windows series since older days of Windows XP. But still the fact is that many newbies to Windows aren’t aware of them. In this article, we’ll let you know about these variables and show the way to edit or modify them.

Basically, environment variables are strings that contain information such as drive, path, or file name. They control the behavior of various programs. For example, %windir% is an environment variable which when run in Command Prompt, opens the Windows folder under system root drive such as C:\Windows. There are two kind of environment variables a Windows operating system have. The first category is of user environment variables, which the user(s) and/or administrator(s), both can modify anytime. Second class is of system environment variables, which only system admin(s) can modify.

Keep in mind that the user environment variables are different for each user of a particular computer. The variables include any that are set by the user, as well as any variables defined by programs, such as the path to the location of the program files. While for system environment variables, administrators can change or add environment variables that apply to the system, and thus to all system users. During installation, Windows Setup configures the default system variables, such as the path to the Windows files.

How To Change User And System Environment Variables In Windows 10

1. Open administrative or elevated Windows PowerShell. For this search in Windows by term windows powershell, pick Windows PowerShell from search results, right click on it and select Run as administrator.

Recommended : Use Windows PowerShell to find Windows Experience Index on Windows 10

2. Next, in the Windows PowerShell window, type following cmdlet and press Enter key:

Get-ChildItem Env:

How To Change System And User Environment Variables In Windows 10

This cmdlet output will show you the list all environment variables available on your system. You can also edit or modify the variables in Windows PowerShell itself, but this would be bit technical. So for the sake of readers, I’ll show you much familiar way to edit these variables.

Registry Disclaimer: The further steps will involve registry manipulation. Making mistakes while manipulating registry could affect your system adversely. So be careful while editing registry entries and create a System Restore point first.

3. Press Windows Key + R and put regedit in Run dialog box to open Registry Editor (if you’re not familiar with Registry Editor, then click here). Click OK.

Windows 10 Registry Editor

4. In the left pane of Registry Editor, navigate to following registry key:

HKEY_CURRENT_USER\Environment

How To Change System And User Environment Variables In Windows 10

5. At this registry location as shown above, you can see there are two user environment variables by default. To add a new environment variable, right click on blank space in the right pane, select New -> Expandable String Value. Change the string name so created from New Value #1 to whatever you want to say the variable. Now, for existing variables, double click on the variable string to add or modify its Value data:

How To Change System And User Environment Variables In Windows 10

Put you desired Value data in Edit String window and click OK. In this way, you can add or modify user environment variables.

6. In order to modify system environment variables, navigate to following registry key and perform the registry manipulation as described in previous step:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

How To Change System And User Environment Variables In Windows 10

We’ve highlighted some important variables in the screenshot above. So in this way, you can add or modify system environment variables. You may need to restart your system, to make your changes effective.

List of environment variables in Windows 10

For your convenience, here is the complete list of environment variables in Windows 10.

ENVIRONMENT VARIABLES
VALUES (items in italic – variables)
%ALLUSERSPROFILE% C:\ProgramData
%APPDATA% C:\Users\(user-name)\AppData\Roaming
%CD% Current directory full path
%CMDCMDLINE% Returns exact command line used to start current cmd.exe session.
%CMDEXTVERSION% Number of current command processor extensions.
%CommonProgramFiles% C:\Program Files\Common Files
%CommonProgramFiles(x86)% C:\Program Files (x86)\Common Files
%CommonProgramW6432% C:\Program Files\Common Files
%COMPUTERNAME% Technoyl-PC
%COMSPEC% C:\Windows\System32\cmd.exe
%DATE% Current date in format determined by Date command
%ERRORLEVEL% Number defining exit status of previous command or program
%HOMEDRIVE% C:
%HOMEPATH% C:\Users\(user-name)
%LOCALAPPDATA% C:\Users\(user-name)\AppData\Local
%LOGONSERVER% \\MicrosoftAccount
%NUMBER_OF_PROCESSORS% 1
%OS% Windows_NT
%PATH% C:\WINDOWS

C:\WINDOWS\system32

C:\WINDOWS\System32\Wbem

C:\WINDOWS\System32\WindowsPowerShell\v1.0

%PATHEXT% COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
%PROCESSOR_ARCHITECTURE% x86
%PROCESSOR_IDENTIFIER% x86 Family 6 Model 69 Stepping 1, GenuineIntel
%PROCESSOR_LEVEL% 6
%PROCESSOR_REVISION% 4501
%ProgramData% C:\ProgramData
%ProgramFiles% C:\Program Files
%ProgramFiles(x86)% C:\Program Files (x86)
%ProgramW6432% C:\Program Files
%PROMPT% Code for current command prompt format. Code is usually $P$G
%PSModulePath% C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
%PUBLIC% C:\Users\Public
%RANDOM% To get random number between 0 and 32767
%SessionName% When logging on directly to machine, returns “Console”.

When client connects via terminal server session, is combination of

connection name, followed by pound symbol {#} and session number.

%SystemDrive% C:
%SystemRoot% C:\Windows
%TEMP% C:\Users\(user-name)\AppData\Local\Temp
%TIME% Current time in format determined by Time command
%TMP% C:\Users\(user-name)\AppData\Local\Temp
%USERDOMAIN% Technoyl-PC
%USERDOMAIN_ROAMINGPROFILE% Technoyl-PC
%USERNAME% (user-name)
%USERPROFILE% C:\Users\(user-name)
%WINDIR% C:\Windows

Hope you find the article useful! Also learn how to scan your Windows 10 using Windows PowerShell.

15 Comments

Add your comment

  • Sean

    Hey! Thanks for this. The link in Windows 10 for setting user environment variables doesn’t work, so this is now the only way to do it until that’s fixed. Just wanted to thank you and add that text so search engines point to your page as a solution. Thanks again.

  • Kapil Arya

    ^^ Glad it helped 😊

  • craig

    this was helpful, thanks

  • Kapil Arya

    ^^ Welcome!

  • Octo Podi

    I notice

    rundll32 sysdm.cpl,EditEnvironmentVariables

    works too.

  • Fabienne G Bonzon

    thank you, it worked for me!

  • Kapil Arya

    ^^ Glad we could help 😎

  • Old bug

    This won’t help if Windows Regedit shows the system PATH that is different from what’s seen in the PowerShell. I had edited it with the Windows’ Env variable dialog, with which I set new path entry and delete old one. When run my program, however, the Windows can’t find the new path, but keeps going back to the old one. Then I found that the path displayed with PowerShell is still the old one, but the regedit displays the new one. This is obviously a bug, and from what I found on the net (as of 2019, April 3), it has been around since 2016, 3 years passed without being fixed.

  • Raj Dhawan

    Great Job my friend. So Helpful!

  • Kapil Arya

    ^^ Glad to hear that!

  • AMAN VATS

    I followed same steps to create user environment variable. But even then it didn’t appear when I opened it in file explorer. Where’s the problem?

  • Kapil Arya

    ^^ What steps you exactly performed?

  • ghanni patel

    what if we directly want to set it from vscode teminal as i need to use env variable a lot and it doesnt changes and if i follow edit in env process then pc needs a restart to impose the new env or changes made .
    eg : set PORT = 4000
    this wont work from terminal which it does in other pc & if done with help of regeit or advanced sys settings pc needs restart to set that env var.

  • PAVANKUMAR OBULAPURAM

    Thank you bro. It helped me to set environment variables

  • Kapil Arya

    ^^ Glad to help!

  • Leave a Reply

    Your email address will not be published. Required fields are marked *