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 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?
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 would 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-looking one) 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 at 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, Xbox PC app, and more. You 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, see the FAQs at bottom). 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 which 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.
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 down 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 exact 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 exact same job but for x86-based (32-bit) programs and utilities only.
- The variable opens a sub-directory where you can view all the files shared by separately installed programs.
- For any program, you can access common components present in both 64-bit or 32-bit folders. These include frameworks, Services, and DLL files.
%COMSPEC% or %ComSpec% is a short-cut text entry used in Run menu to open the Command Prompt. It uniquely displays the entire Command Line path “C:WindowsSystem32Cmd.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 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 “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:WindowsSystem32Drivers.” This is a central folder containing all your driver information.
- As the folder is accessible to “System Restore”, SFC, and other internal processes, its variable is very handy to look out for possible errors.
- While installing any new hardware, use the variable to check if the DriverData folder hasn’t 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 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 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 run certain games and applications for which you want to know whether your device will support them.
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 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 in your PC.
- View all your Windows Path files in one place. This includes the routine “C:WindowsSystem32” 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% lets you know all the file extension types that 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.
So 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 in installing 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 on 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 indicating 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 chip-maker.
Every processor while being designed goes through a series of design iterations. So
echo %Processor_Revision% tells you the exact 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 for a better designed 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. Keeping it always 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 applications folders. This would allow 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? In such a case, %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 or not 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 consist 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.exelies in the right folder.
The Windows PowerShell script uses various modules located in different parts of Windows PC. The variable %PSModulePath% used as
echo %PSModulePath% displays all 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.
- With a
%PSModulePath%variable, you can access them centrally without having to search for them individually.
The variable %Public% when typed in Run menu reveals the public users folder located at
C:UsersPublic. It stores all the documents, downloads, music, and pictures attached to the publicly accessible folder.
- Getting a bird’s eye view of all user accounts registered in a Windows device.
- Sharing data with others using your computer or on a 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 lead to an output 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 if 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 hosted on a machine is local to the device. This problem can be addressed using
- If the SessionName is shown as “Console” then you clearly know that the session is local to your device.
- In the same way 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 %SystemRoot% variable in Run menu. Also check %WinDir% below.
- 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:UsersAppDataLocalTemp”, 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 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 the username in which it exists.
- 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 latest Windows devices.
- Centrally access error reports pertaining to system faults, as all of them link to %WinDir% variable, and its location
- 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 CPU have been initialized.
- On some Windows devices, you can use
echo %ZES_ENABLE_SYSMAN_LOW_POWER%to ensure low power settings. Thus both these Sysman commands can be used to turn the current low power settings On or Off.
Frequently Asked Questions
How to resolve Windows environment variables not recognized?
If one or more of your Windows environment variables are not being recognized, it is possible that there settings are missing in your device. Go to “View Advanced System Settings” from search menu and open Environment Variables. Then add those missing environment variables one by one. Close the window and try resolving the issue.
How to export and import environment variables in Windows?
To export or import environment variables in Windows, you need to open the Registry Editor from Run menu (regedit.exe). You will find environment variables here under “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment” and “HKEY_CURRENT_USEREnvironment.” 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 right at their respective locations. We have a detailed guide on how to set variables correctly.
Image credit: Pixabay All screenshots by Sayak Boral
Is this article useful?
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox