Environment variables are necessary for specifying absolute paths to folders and are often used in batch (command) files. For example, if you do not know the letter of your system drive, you can always use the %systemdrive% variable, which returns the letter of the drive where Windows is installed.
Also, variables are used for code optimization, for example, you can assign a short variable for a repeated parameter and use it.
List of basic Windows environment variables
The table shows a list of the main variables of the Windows environment.
Variable | Significance |
---|---|
%ALLUSERSPROFILE% | C:\\ProgramData |
%APPDATA% | C:\\Users\\User_Name\\AppData\\Roaming |
%CommonProgramFiles% | C:\\Program Files\\Common Files |
%CommonProgramFiles(x86)% | C:\\Program Files (x86)\\Common Files |
%CommonProgramW6432% | C:\\Program Files\\Common Files |
%COMPUTERNAME% | Computer_name |
%ComSpec% | C:\\Windows\\system32\\cmd.exe |
%HOMEDRIVE% | C: |
%HOMEPATH% | \\Users\\User_Name |
%LOCALAPPDATA% | C:\\Users\\User_Name\\AppData\\Local |
%LOGONSERVER% | Computer_name |
%NUMBER_OF_PROCESSORS% | Number_of_processors |
%OS% | Windows_NT |
%Path% | C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32Wbem; |
%PATHEXT% | .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC |
%PROCESSOR_ARCHITECTURE% | x86 or AMD64 |
%PROCESSOR_IDENTIFIER% | Intel64 Family 6 Model 37 Stepping 5, GenuineIntel (example) |
%PROCESSOR_LEVEL% | 6 |
%PROCESSOR_REVISION% | 2505 (example) |
%ProgramData% | C:\\ProgramData |
%ProgramFiles% | C:\\Program Files |
%ProgramFiles(x86)% | C:\\Program Files (x86) |
%ProgramW6432% | C:\\Program Files |
%PROMPT% | $P$G |
%PSModulePath% | C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\ |
%PUBLIC% | C:\\Users\\Public |
%SystemDrive% | C: |
%SystemRoot% | C:\\Windows |
%TEMP% | C:\\Users\\User_Name\\AppData\\Local\\Temp (by default) |
%TMP% | C:\\Users\\User_Name\\AppData\\Local\\Temp (by default) |
%USERDOMAIN% | Computer_name |
%USERDOMAIN_ROAMINGPROFILE% | Computer_name |
%USERNAME% | User_Name |
%USERPROFILE% | C:\\Users\\User_Name |
%windir% | C:\\Windows |
How to find out the list of variables on the command prompt
To find out the list of variables, open a command prompt and run the set command.
After executing the command, a list of environment variables will be displayed.
You can also redirect the output of the results of a set command to a text file by executing the following command:
set > E:\Variables.txt
where E:\ is the drive letter, Variables.txt is the text file to which the output is redirected.
The variables will be stored in a text file.
How to find out the list of variables in the Registry Editor
To view system environment variables in the registry editor, you need to open the registry branch:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
To view custom environment variables in the registry editor, you need to open the registry branch:
HKEY_CURRENT_USER\Environment