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.

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.

Uses

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.

2. %CD%

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.

Uses

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.

3. %CommonProgramFiles%

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.

Uses

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.

4. %COMSPEC%

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

Uses

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.

Uses

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.

6. %DriverData%

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

Uses

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.

7. %HomeDrive%

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.

Uses

Access C:\ drive from anywhere on your PC.Link with other environment variables, such as %CD% or %CommonProgramFiles%.

8. %LogOnServer%

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.

Uses

Quickly find out the Windows Logon server to which you’re authenticated.Validate your user login to the correct Microsoft account.

9. %Number_Of_Processors%

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.

Uses

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.

10. %OneDrive%

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

Uses

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.

11. %OS%

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.

Uses

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.

12. %Path%

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

Uses

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.

13. %PathExt%

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.

Uses

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.

14. %Processor_Architecture%

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.

Uses

Knowing the exact architecture your Windows device uses is helpful when you install compatible games and applications.

15. %Processor_Identifier%

The 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.”)

Uses

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.

16. %Processor_Level%

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.

Uses

Validating that you have the right processor capabilities on your processor as advertised by the chip-maker.

17. %Processor_Revision%

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.

Uses

When buying a new laptop, you can use this variable to make an informed decision in choosing a chipset.

18. %ProgramData%

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.

Uses

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.

19. %ProgramFiles%

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.

Uses

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.

20. %Prompt%

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.

Uses

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.exe is in the right folder.

21. %PSModulePath%

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.

Uses

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.

22. %Public%

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.

Uses

Getting a birds-eye view of all user accounts registered in a Windows device.Sharing data with others via your computer or network.

23. %Random%

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.

Uses

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.

24. %SessionName%

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 echo %SessionName%.

Uses

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.

25. %SystemRoot%

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

Uses

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.

26. %Temp%

One of the best known applications of environment variables, the temporary files folders can be accessed using %Temp% or %Tmp% in Run menu.

Uses

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.

27. %UserDomain%

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 echo %UserDomain%.

Uses

Mapping the current PC user’s desktop session with its username.Setting up Group user policies for several users.

28. %UserProfile%

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.

Uses

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

29. %WinDir%

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.

Uses

Centrally access error reports pertaining to system faults, as all of them link to the %WinDir% variable and its location C:\Windows.The WinDir folder is closely linked to the administrator account and 64-bit applications.

30. %ZES_ENABLE_SYSMAN%

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 echo %ZES_ENABLE_SYSMAN%.

Uses

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.

Image credit: Pixabay All screenshots by Sayak Boral