Windows Batch Variables

List of Windows Environment Variable

Commonly used variables used in Windows Batch Scripts, etc…

Variable Description Example Value
%ALLUSERSPROFILE% Path to the All Users Profile C:\Documents and Settings\All Users
%APPDATA% Path to location of default applications data store C:\Documents and Settings\JDoe\Application Data
%CD% Path to the current directory c:\windows\system32
%CMDCMDLINE% Path to the command line (cmd.exe) used to start the current session “C:\WINDOWS\system32\cmd.exe”
%CMDEXTVERSION% Version number of the current Command Processor Extensions 2
%COMPUTERNAME% Name of the computer MYCOMPUTER
%COMSPEC% Path to the command shell executable C:\WINDOWS\system32\cmd.exe
%DATE% Current date. (Same as the date /t command) Mon 1/1/2000
%ERRORLEVEL% Error code of the last command 0 (Zero usualy means no errors)
%HOMEDRIVE% User’s home drive letter as set in the domain. U:
%HOMEPATH% Path to User’s home directory as set in the domain \
%HOMESHARE% Path to the user’s shared home directory as set in the domain \\server\users\JDoe
%LOGONSEVER% Name of the domain controller that validated the current session \server
%NUMBER_OF_PROCESSORS% System specifies the number of processors installed on the computer 1
%OS% Operating System Name. Windows_NT
%PATH% Search path for executables C:\WINDOWS\system32;C:\WINDOWS
%PATHEXT% A List of the file extensions that are executable .COM;.EXE;.BAT;.CMD
%PROCESSOR_ARCHITECTURE% Processor’s chip architecture x86
%PROCESSOR_IDENTIFIER% Description of the processor x86 Family 15 Model 1 Stepping 2, GenuineIntel
%PROCESSOR_LEVEL% Model number of the processor 15
%PROCESSOR_REVISION% Revision number of the processor 102
%PROMPT% List of command-prompt settings $P$G
%RANDOM% Random decimal number between 0 and 32767 1234
%SYSTEMDRIVE% Drive letter containing the Windows directory C:
%SYSTEMROOT% Path to Windows directory C:\WINDOWS
%TEMP% Path to temporary directory (Same as TMP) C:\DOCUME~1\JDoe\LOCALS~1\Temp
%TIME% Current time. (Same as the time /t command) 12:00:00.00
%TMP% Path to temporary directory (Same as TEMP) C:\DOCUME~1\JDoe\LOCALS~1\Temp
%USERDOMAIN% Name of the User’s domain MY-DOMAIN
%USERNAME% User name of the Currently logged User JDoe
%USERPROFILE% Path to the profile for the currently logged on user C:\Documents and Settings\Jdoe
%WINDIR% Path to the Windows directory C:\WINDOWS

Leave a Reply