List of Windows and DOS Command Prompt Environment Variables

Windows and DOS (Command Prompt) have several environment variables which provides a set of dynamic values that points to important system locations or settings. Environment variables provided a way for running programs and batch command script to access the true discrete values, system paths or user management settings for configuration and processing purposes, avoiding the use of hard-coded values which may fail on some systems due to great variety of system configuration.

Tip: Batch file (.bat or .cmd) also uses environment variables to store temporary values for reference later in the script, and also to communicate data and preferences to child processes.

The table lists the common built-in environment variables in Windows operating system, together with their brief explanations and default values. All environment variables is not case-sensitive.

Variable Usage Windows XP Windows Vista and Windows 7
%AllUsersProfile% Expand to full path to the All Users profile directory which contains resources such as shortcuts for Start Menu and Desktop for all users. {SystemDrive}:\Documents and Settings\All Users {SystemDrive}:\ProgramData
%AppData% Contain full path to the Application Data folder of the logged-in user. {SystemDrive}:\Documents and Settings\{username}\Application Data {SystemDrive}:\Users\{username}\AppData\Roaming
%CD% Display current working directory or folder.
%ComputerName% {ComputerName} {ComputerName}
%CommonProgramFiles% Point to Common Files directory. {SystemDrive}:\Program Files\Common Files {SystemDrive}:\Program Files\Common Files
%CommonProgramFiles(x86)% Only available in 64-bit (x64) OS, and point to Common Files directory in 32-bit Program Files folder. {SystemDrive}:\Program Files (x86)\Common Files {SystemDrive}:\Program Files (x86)\Common Files
%ComSpec% Display full path to the command processor (Cmd.exe on Windows NT based OS and Command.exe on Windows 9x and ME). {SystemDrive}:\Windows\System32\cmd.exe {SystemDrive}:\Windows\System32\cmd.exe
%Date% Display current date in regional format.
%ErrorLevel% Point to current error level, normally used to check error returned from previous command.
%HomeDrive% Point to the drive for current signed on user’s home folder. {SystemDrive}:\ {SystemDrive}:\
%HomePath% Point to the signed on user’s home folder. {SystemDrive}:\Documents and Settings\{username} {SystemDrive}:\Users\{username}
%LogonServer% Hold the hostname of the server that authenticated the current user’s logon credentials (name and password), normally own PC or domain controller.
%Path% Contains a semicolon-delimited list of directories in which the command interpreter will search for executable files. {SystemDrive}:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} {SystemDrive}:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths}
%PathExt% Contains a semicolor-delimited list of extensions which are defined as exectable. .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.WSF;.WSH .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc
%ProgramFiles% Point to Program Files directory, which stores all the installed program of Windows and others. {SystemDrive}:\Program Files {SystemDrive}:\Program Files
%ProgramFiles(x86)% Only available in 64-bit version, the variable force accesses to 32-bit Program Files folder bypassing Windows-on-Windows 64-bit redirection. {SystemDrive}:\Program Files (x86) {SystemDrive}:\Program Files (x86)
%ProgramW6432% Only available in 64-bit version, the variable force accesses to 64-bit Program Files folder. {SystemDrive}:\Program Files {SystemDrive}:\Program Files
%Prompt% Display code for current command prompt format. $P$G $P$G
%Random% Return a random number between 0 and 32767.
%SystemDrive% Point to the drive where the system folder is placed. C: ({SystemDrive} or any other drive letter) C: ({SystemDrive} or any other drive letter)
%SystemRoot% Display full path location of the system folder. {SystemDrive}:\Windows (fomerly C:\WINNT and C:\WINNT35) {SystemDrive}:\Windows
%Temp% and%Tmp% Point to temporary folder. {SystemDrive}:\Documents and Settings\{username}\Local Settings\Temp {SystemDrive}:\Users\{username}\AppData\Local\Temp
%Time% Display current time in regional format.
%UserDomain% Hold the name of the Workgroup or Windows Domain to which the current user belongs.
%UserName% Display currently logged on active user’s account identification name. {UserName} {UserName}
%UserProfile% Return location of the current user’s profile directory as defined in HKCU registry hive (NTUSER). {SystemDrive}:\Documents and Settings\{username} {SystemDrive}:\Users\{username}
%WinDir% Similar %SystemRoot% and point to Windows directory. {SystemDrive}:\Windows (C:\WINNT for previous OS and C:\WTSRV for NT4 Terminal Server Edition) {SystemDrive}:\Windows
%Public% Display full path to Public Application Data folder. {SystemDrive}:\Users\Public

10 Responses to “List of Windows and DOS Command Prompt Environment Variables”

  1. John
    November 26th, 2009 18:21
    10

    Am having problem with the environment viraiables

    because i have been deleted all my viariables and values by mistake

    Help me if u have solution for this issue
    its sticking my life
    PLEASE!!!!!!!!!!!!!!!!
    Panit and such as cmd are fully not working.
    THANKS IN ADVANCE!!!!!!!
    MY OS 7 Ultimate.

  2. wwwwww
    November 26th, 2009 13:59
    9

    crappy web with bogus adds

  3. fuzzy
    November 14th, 2009 01:40
    8

    I can’t read the page ads are covering the text tested in IE 6,7 and 8, Firefox, Opera, and Safari. The page can only be displayed so you can read it in IE 6 which makes it unreadable to anyone running Vista or higher. The quick fix would be wrap the page in a div with an overflow see http://www.w3schools.com if you need help.

  4. deepakhs
    August 31st, 2009 15:06
    7

    good required is displayed

  5. jas
    August 4th, 2009 04:06
    6

    dont design your site for ie only

  6. Vishal
    June 29th, 2009 15:30
    5

    View page in IE. It displays correctly.

  7. Joe Smith
    April 3rd, 2009 23:10
    4

    Your crappy website has ads overlaying the info!!

  8. Nkosana
    March 27th, 2009 22:24
    3

    no i cannot

  9. reader
    March 8th, 2009 07:06
    2

    the ads on this page make it very difficult to read your helpful information :(

  10. Abhilash
    January 19th, 2009 19:42
    1

    Thats nice.
    Thankx a lot.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

windows 7 environment variables - dos command list - dos variables - dos commands list - windows 7 variables - windows 7 dos commands - environment variables windows 7 - dos environment variables list - windows 7 user variables - command prompt environment variables - Environment of DOS COMMAND - "windows 7" environment variables - windows 7 system variables - view environment variables windows - command prompt code list - windows prompt environment variable - win 7 dos command - dos environment variable - Windows 7 Environment variables - users public variable windows 7 - "common files directory" vista - cmd codes list - DOS VIEW VARIABLE VALUES - dos commands for documents and settings - expanding environment variable for Windows 7 scripting - list environment variables windows 7 - windows search variables - *list DOS Command to list open programs - all - dos command list drives - dos view environment variables windows - environment variables windows - windows command line location of environment program - windows command line variable list - command prompt variable - documents and settings variable + domain - dos command prompt to check user accounts - system variables win 7 - variable windows 7 - dos system variables - list environment variables windows - windows 7 directory variable - windows 64 bit operating system+query installed program from command line - DOS Variables list - environment variables for windows 7 - environment variable windows 7 - listing windows system variables - to list enviroment variables in command prompt - variable windows directory - windows7 environment variables -