Windows environment variables are commonly-used short-cut commands to open a folder path in Windows. Whether you want to locate specific folders or troubleshoot a bug, you can perform these tasks quickly by typing environment variables in the Run menu or Command Prompt. The following is a complete list of system and user environment variables in Windows 10 and Windows 11.
- What Are Windows Environment Variables?
- How to Access Environment Variables in Windows
- System vs. User Environment Variables
- 1. %AppData% and %LocalAppData%
- 2. %CD%
- 3. %CommonProgramFiles%
- 4. %COMSPEC%
- 5. %Date% or %Time%
- 6. %DriverData%
- 7. %HomeDrive%
- 8. %LogOnServer%
- 9. %Number_Of_Processors%
- 10. %OneDrive%
- 11. %OS%
- 12. %Path%
- 13. %PathExt%
- 14. %Processor_Architecture%
- 15. %Processor_Identifier%
- 16. %Processor_Level%
- 17. %Processor_Revision%
- 18. %ProgramData%
- 19. %ProgramFiles%
- 20. %Prompt%
- 21. %PSModulePath%
- 22. %Public%
- 23. %Random%
- 24. %SessionName%
- 25. %SystemRoot%
- 26. %Temp%
- 27. %UserDomain%
- 28. %UserProfile%
- 29. %WinDir%
- 30. %ZES_ENABLE_SYSMAN%
- Frequently Asked Questions
What Are Windows Environment Variables?
Environment variables in Windows are commands that launch a folder path using a brief text string within percent sign characters (%). The “environment” here refers to the runtime in which a program is executed. In fact, the purpose of these commands is to impact various running processes on your computer.
Popular environment variable examples are “%AppData%,” “DriverData%,” “%temp%,” and “%WinDir%.” You may have used them in Run menu or Command Prompt without actually knowing that they’re called environment variables.
How to Access Environment Variables in Windows
It’s very easy to check all the environment variables present on a Windows device.
- Launch “View advanced system settings” using the Search button (magnifying glass) in Windows.
- Alternatively, open Settings using Win + I, tap on “System -> About -> Advanced system settings.”
- Go to the “Advanced” tab and click “Environment Variables” under “Startup and Recovery.”
System vs. User Environment Variables
From the above menu option, you can see all the default/standard environment variables in one place. These are further classified into two categories:
- User environment variables: these refer to user-centric file and folder paths. You can add shortcuts to any program you use, such as OneDrive, Microsoft Office, an Xbox PC app, and more and can freely edit and even delete the contents of the user environment variables.
- System environment variables: these are the system-centric file and folder paths. While you can add new system environment variables (only if missing). Do not edit or delete the existing ones, as that may harm your device.
1. %AppData% and %LocalAppData%
%AppData% points toward the AppData Roaming folder that is connected to your Windows user profile. Roaming means that your user login information can be transferred from one Windows device to another. In contrast, %LocalAppData% opens local user profile folders created on a Windows PC.
- Locating and clearing unnecessary files, settings, and data accumulating in AppData folders.
- Admin user taking back full ownership of important system and registry files from TrustedInstaller.
CD (change directory) is a common text string used to switch directory paths in Windows Command prompt and PowerShell. Thus, the %CD% variable tells you the precise execution directory in which you are running your code.
- After scrolling through several lines of text in Command Prompt, it’s easy to forget which is the current working directory. Typing
echo %CD%gives you the current one.
- If running multiple Command prompts at once, %CD% saves you the trouble of identifying the correct working directory.
The %CommonProgramFiles% variable refers to a Windows directory named “Common Files.” It contains many types of 64-bit files and folders shared among various apps. Another related variable, %CommonProgramFiles(x86)%, does the same job but for x86-based (32-bit) programs and utilities only.
- The variable opens a sub-directory where you can view all of the files shared by separately-installed programs.
- For any program, you can access common components present in both 64-bit and 32-bit folders. These include frameworks, Services, and DLL files.
%COMSPEC% or %ComSpec% is a shortcut text entry used in the Run menu to open the Command Prompt. It uniquely displays the entire Command Line path “C:\Windows\System32\Cmd.exe” on the window title.
- Engage with the Command Line directly from any location on your PC.
- If you’re running a computer with no hard disk, you can boot the device by launching CMD along with a configured RAM disk and USB drive.
5. %Date% or %Time%
As the name suggests, the environment variables %Date% and %Time% are used to display the current date and time on your device. A correct output will confirm that the latest date and time settings are in effect.
- This variable is used to verify whether the current system date and time are correct.
- Changing the current date and time according to “mm-dd-yy” and the “0:hh:mm:ss” 24-hour format.
%DriverData% is a variable that refers to the DriverData folder on your Windows PC. It is located at “C:\Windows\System32\Drivers.” This is a central folder containing all of your driver information.
- As the folder is accessible to “System Restore,” SFC, and other internal processes, its variable is very handy for locating possible errors.
- While installing any new hardware, use the variable to check whether the DriverData folder has been affected.
The all-important C:\ drive is crucial to everything you do on your system. A command like %HomeDrive% (or %SystemDrive%) helps you open and view the location for further activity.
- Access C:\ drive from anywhere on your PC.
- Link with other environment variables, such as %CD% or %CommonProgramFiles%.
Every computer is connected to a a domain group or network of devices. %LogOnServer% displays the current Windows Logon server, which can be as simple as your computer name (below) or a corporate domain.
- Quickly find out the Windows Logon server to which you’re authenticated.
- Validate your user login to the correct Microsoft account.
As the name suggests, %Number_Of_Processors% gives out the number of cores on your Windows CPU. The command returns a simple numeric value referring to the number of processor cores your device has.
- Whether your PC has a dual (2), quad (4) or octa-core (8) processor configuration, using
echo %Number_Of_Processors%is the fastest way to find out.
- This is very useful when you want to learn whether you device will support certain games and applications that you want to run.
The OneDrive folder contains all its essential applications, such as the Desktop, documents, and any files and folders synced with Microsoft’s Cloud servers. To open this folder, you can use its namesake environment variable, %OneDrive%.
- Quickly access your Microsoft Cloud data from any location on your PC.
- When using the OneDrive folder with Command Line, this variable will open the entire network path.
Windows has been running its proprietary Windows NT operating system since 1993. Running an operating system-specific command like
echo %OS% gives you a quick glimpse into your current operating system.
- If you want to ensure that your current version of Windows is a valid copy (and not a pirated one), this variable gives you the confirmation.
%Path% is one of the most common environment variables to be used on your Windows 10/11 device. When you run an
echo %Path%, it gives you all the important Path files available on your PC.
- View all your Windows Path files in one place. This includes the routine “C:\Windows\System32” and other file locations for PowerShell, WindowsApps and OpenSSH.
- You can utilize these Path file locations with other commands.
While installing native and third-party apps in Windows, you come across many files with extensions, such as .COM, .EXE, .BAT (Batch files), .VBS, .VBE, and so forth. %PathExt% makes you aware of all the file extension types you need to watch out for in the %Path% variable.
- Know all the file extensions that can be executed from Command Prompt.
- Start a program or script in Command line without specifying the suffix, such as .EXE.
What kind of microprocessor does your Windows device contain? With a variable
echo %Processor_Architecture%, you can easily tell whether you’re using Intel or AMD (or any other CPU), and whether it’s 64 or 32-bit.
- Knowing the exact architecture your Windows device uses is helpful when you install compatible games and applications.
echo %Processor_Identifier% variable goes deeper into CPU-specific information, including processor family and model series, whether it’s Genuine Intel or AMD, and what level of design change a processor was built into. (It’s called processor “stepping.”)
- Advanced applications, such as creating Windows batch scripts or testing hardware failure.
- Testing the hardware compatibility of external components, such as motherboard, RAM etc., with your Windows device.
In analyzing chip architecture,
echo %Processor_Level% displays the processor level showing the model number of the CPU installed in your device. It is expressed numerically as 3,4, 5 (for x86) to 6 for (x64) computers.
- Validating that you have the right processor capabilities on your processor as advertised by the chip-maker.
While each processor is being designed, it goes through a series of design iterations.
echo %Processor_Revision% tells you the revision number of the installed CPU. In other words, it lets you know how advanced a processor is.
- When buying a new laptop, you can use this variable to make an informed decision in choosing a chipset.
Much like Program Files, the Program Data folder is used by Windows to install standard applications but does not require higher level Administrator privileges. Using %ProgramData% gives you easy access to this folder.
- Malware authors often try to attack the ProgramData folder, as tampering with its files can affect installed apps. Always keeping it hidden is important.
- As an Admin user, you should stay on top of any changes in the folder. Use “System Restore” if you notice any errors.
The %ProgramFiles% and %ProgramFiles(86)% variables directly launch the respective Program Files and Program Files for 32-bit application folders. This allows you to view all your installed file components.
- Add, edit and delete any program files directly in this section.
- Are you unable to access the File Explorer for any reason? If so, %ProgramFiles% from the Run menu gives you quick access to this folder.
The Prompt variable, %Prompt%, gives an indication of the current Command Prompt, validating whether your Command Prompt executable,
cmd.exe is present in the correct folder path. It is written as
echo %Prompt% and returns specific values as shown below.
- The output Prompt text can be returned. It consists of various characters, where $P refers to a current drive and path, and $G means equal to or greater than. Thus, if you get an output such as $P$G, it means your
cmd.exeis in the right folder.
The Windows PowerShell script uses various modules located in different parts of a Windows PC. The %PSModulePath% variable used as
echo %PSModulePath% displays all of the various locations for it, such as Program Files or System32.
- PowerShell modules contain various components, such as Cmdlets, Providers, workflows, and aliases. These are frequently used in coding activity in sync with the main PowerShell window.
- You can access them centrally with a
%PSModulePath%variable without having to search for them individually.
The variable %Public% when typed in the Run menu reveals the public users folder located at
C:\Users\Public. It stores all the documents, downloads, music, and pictures attached to the publicly accessible folder.
- Getting a birds-eye view of all user accounts registered in a Windows device.
- Sharing data with others via your computer or network.
The Command Prompt has its own variable, %Random%, which is used to generate a random number between 0 to 32767. To use it, you need to type
echo %Random%, which will generate a number, such as 21907 shown here.
- Random numbers are often used in Windows batch scripts for testing purposes.
- If you are facing issues with numeric display on your device, test whether the random numbers are displaying correctly in Command line.
If you are frequently using remote desktops, it may become hard to tell whether the current session being hosted is local to the device. This problem can be addressed using
- If the SessionName is shown as “Console,” you know that the session is local to your device.
- Similarly, if you see an Output such as “RDP-Tcp#,” it will inform you whether you’re using a Remote Desktop session.
The System Root of your folder,
C:\Windows, contains many utilities that are integral to your device performance. They can all be centrally accessed from the %SystemRoot% variable in theRun menu. Also check %WinDir%..
- Accessing Control Panel applications as they’re directly linked to System Root folder.
- The System Root contains utilities such as “Fonts.” You can directly open these folder paths from Run menu and operate on them using Command Prompt.
One of the best known applications of environment variables, the temporary files folders can be accessed using %Temp% or %Tmp% in Run menu.
- Instead of remembering the entire path “C:\Users\AppData\Local\Temp,” you can simply open the temporary files folder with a simple and easy to remember command.
- Delete as many temporary files as you want to free up space on your device and improve PC performance.
Every desktop device is marked by a user domain. To know where your current user is being hosted, you can check the domain with an environment variable called %UserDomain%. It has to run with an echo command as
- Mapping the current PC user’s desktop session with its username.
- Setting up Group user policies for several users.
If there are multiple usernames registered on a Windows device, it becomes difficult to tell which user is connected to a current desktop profile. Using a Run menu variable, such as %UserProfile%, will get you a complete view.
- Accessing and managing multiple user profiles registered on a Windows PC.
- Deleting and editing the desktop, documents, and downloads for multiple user profiles (something only Admin users can do).
The %WinDir% is similar to %SystemRoot%, in that both point to the
C:\Windows location on your PC. However, unlike the latter, WinDir can be used to launch standard Windows system calls to open a folder or get a specific output. It is also more commonly used in the latest Windows devices.
- Centrally access error reports pertaining to system faults, as all of them link to the %WinDir% variable and its location
- The WinDir folder is closely linked to the administrator account and 64-bit applications.
Sysman means System Resource Management library. This covers many things in Windows 11/10, such as power management of various system components. To enable this setting, you need to input
- If the Output value returns itself as 1, then it means that the default SysMan settings for the CPU have been initialized.
- On some Windows devices, you can use
echo %ZES_ENABLE_SYSMAN_LOW_POWER%to ensure low power settings. Thus, both Sysman commands can be used to turn the current low power settings On or Off.
Frequently Asked Questions
How can I resolve Windows environment variables that are not recognized?
If one or more of your Windows environment variables are not being recognized, it is possible that their settings are missing on your device. Go to “View Advanced System Settings” from the search menu and open Environment Variables, then add those missing environment variables one by one. Close the window and try resolving the issue.
How can I export and import environment variables in Windows?
To export or import environment variables in Windows, you need to open the Registry Editor from the Run menu (regedit.exe). You will find environment variables here under “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” and “HKEY_CURRENT_USER\Environment.” You can export and import the new environment variables in this section’s right panel.
How do I refresh environment variables in Windows?
In the Command Prompt window, using the “cls” command will clear the screen and refresh all the environment variables for you. But to do that properly, you need to first set the variables at their respective locations. See this detailed guide on how to set variables correctly.
Image credit: Pixabay All screenshots by Sayak Boral
Our latest tutorials delivered straight to your inbox