What Are Environment Variables in Windows?
Environment variables store values with a corresponding variable name which are accessible by the user and/or the operating system. The name of the variable is contained within two percent sign characters (%) and is case-insensitive. The environment refers to the runtime in which a program is executed.
Many environment variables are used to point to a folder location and these environment variables can also be used as shortcuts in File Explorer or the Windows Run (Windows key + R) command. Other environment variables store identifying pieces of the computer such as
%OS% which displays the operating system information.
While many of these variables will be used as shortcuts for navigation, they can also be utilized by developers within their applications to grab useful pieces of information about the system or current user. Environment variables are also available for import/export via the Windows system registry.
System vs. User Environment Variables
There are two different types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). Some of the below environment variables apply globally (all users) while others are specifically limited to the current user.
System environment variables deal specifically with system-wide file or folder paths or critical information about the operating system and computer hardware. While it is acceptible to add new system environment variables, you should take caution when editing existing variables and typically should never delete existing variables and their values.
User environment variables are very fluid and can be changed in many cases without harming the operating system functionality. While the scope is limited to the current user, it can still affect the way programs work and is generally not recommended to edit them unless you know exactly what you’re doing.
The List of Environment Variables
REMINDER: The name of the variable is NOT case sensitive!
%appdata% are all valid for use.
In (mostly) alphabetic order, here are all of the default environment variables in Windows 10/11:
|Variable||Description / Default Value|
|%CD%||Outputs current directory path (Command prompt)|
|%CMDCMDLINE%||Outputs command line used to launch current command prompt session (Command prompt)|
|%CMDEXTVERSION%||Outputs the number of current command processor extensions (Command prompt)|
|%COMMONPROGRAMFILES%||C:\Program Files\Common Files|
|%COMMONPROGRAMFILES(x86)%||C:\Program Files (x86)\Common Files|
|%CommonProgramW6432%||C:\Program Files\Common Files|
|%COMPUTERNAME%||Outputs the system computer name (e.g. DESKTOP-LJ6FC)|
|%DATE%||Outputs current date (Command prompt)|
|%ERRORLEVEL%||Outputs the number of defining exit status of previous command (Command prompt)|
|%OS%||Outputs the operating system (e.g. Windows_NT)|
|%PROCESSOR_ARCHITECTURE%||Outputs processor chip architecture (e.g. x86, AMD64)|
|%PROCESSOR_IDENTIFIER%||Outputs description of the processor (e.g. Intel64 Family 6 Model 58 Stepping 9, GenuineIntel)|
|%PROCESSOR_LEVEL%||Outputs model number of the processor (e.g. 6)|
|%PROCESSOR_REVISION%||Outputs revision of the processor (e.g. 3a09)|
|%NUMBER_OF_PROCESSORS%||Outputs number of physical and virtual cores (e.g. 8 = 4 cores, 4 threads)|
|%PROGRAMFILES(X86)%||C:\Program Files (x86)|
|%RANDOM%||Outputs random number from 0 to 32767|
|%TIME%||Outputs time (Command prompt)|
|%USERDOMAIN%||Userdomain associated with current user|
|%USERDOMAIN_ROAMINGPROFILE%||Userdomain associated with roaming profile|
Where Can I Find the Environment Variables in Windows 10/11?
The easiest way to find these settings is first clicking on the Start Menu, then in the search box type “Environment Variables”. You should see an entry under Best Match titled Edit the system environment variables.
Next, you’ll want to click on the button Environment Variables to launch the control panel settings.
From this window, we can see the different sections the environment variables are divided into. The first is User variables and the second is System variables. User variables apply specifically to the current logged in user while the System variables affect the entire computer.
Each section has its own New…, Edit… and Delete buttons. Typically you shouldn’t need to delete any of the variables in the user section and you definitely should NOT delete any of the system variables unless you know exactly what you’re doing.
When you click on New… or Edit… you should receive another dialog box where you can add a new variable or edit an existing one. In this dialog, you can create new entries, edit existing variables, browse for folder paths, delete entries or change the order of the environment variables.
What If I Want to Use the Windows 10/11 Command Prompt or PowerShell Instead?
So far, we’ve taken an in-depth look at how to navigate around in the Windows UI to work with environment variables, but there’s a couple other methods you can use as well: the Windows Command Prompt or Windows PowerShell.
Using Windows Command Prompt to Display List of Environment Variables
If you’re wanting to use the Windows Command Prompt, there are numerous ways to open a command prompt, but one such method is to click on Windows Start then type in “cmd”. Under Best Match you should see the entry for the Command Prompt app. You can choose to run it under the current user or as administrator.
After launching the Command Prompt, you can simply type the command “set” to see the list of all Environment Variables.
Using PowerShell to Display List of Environment Variables
To use Windows PowerShell, first click on Start. Next type in “powershell” in the search field and you will see the item Windows PowerShell App under Best Match.
After launching Windows PowerShell, type in the command:
Get-ChildItem Env:. This will display the list of Environment Variables. To sort the list you can use the command:
Get-ChildItem Env: | Sort Name. This will re-order the list in alphabetic order.
This guide has specifically shown a comprehensive list of environment variables in Windows 10/11, but keep in mind that previous editions of Windows contain many of the same environment variables. To read more about editing the
%PATH% environment variable, check out our article where we explain how to add XAMPP’s PHP execution path.
If you’ve found the tutorial helpful or if you have additional methods for utilizing environment variables in Windows, please leave a comment below and join the discussion!
All screenshots by Michael Smith.