Skip navigation

What environment variables are available in Windows?

You can use environment variables to gain information about a system. For a complete list of environment variables available in Windows, see the following table:

Table 1: Environment Variables

ALLUSERSPROFILELocal returns the location of the All Users Profile.APPDATALocal returns the location where applications store data by default.CDLocal returns the current directory string.CMDCMDLINELocal returns the exact command line used to start the current cmd.exe.CMDEXTVERSIONSystem returns the version number of the current Command Processor Extensions.COMPUTERNAMESystem returns the name of the computer.COMSPECSystem returns the exact path to the command shell executable.DATESystem returns the current date. This variable uses the same format as the date /t command. Cmd.exe generates this variable. For more information about the date command, see the Date command.ERRORLEVELSystem returns the error code of the most recently used command. A non-0 value usually indicates an error.HOMEDRIVESystem returns which local workstation drive letter is connected to the user's home directory. This variable is set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.HOMEPATHSystem returns the full path of the user's home directory. This variable is set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.HOMESHARESystem returns the network path to the user's shared home directory. This variable is set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.LOGONSEVERLocal returns the name of the domain controller that validated the current logon session.NUMBER_OF_PROCESSORSSystem specifies the number of processors installed on the computer.OSSystem returns the OS name. Windows XP and Windows 2000 display the OS as Windows_NT.PATHSystem specifies the search path for executable files.PATHEXTSystem returns a list of the file extensions that the OS considers to be executable.PROCESSOR_ARCHITECTURESystem returns the processor's chip architecture. Values: x86, IA64.PROCESSOR_IDENTFIERSystem returns a description of the processor.PROCESSOR_LEVELSystem returns the model number of the computer's processor.PROCESSOR_REVISIONSystem returns the revision number of the processor.PROMPTLocal returns the command-prompt settings for the current interpreter. Cmd.exe generates this variable.RANDOMSystem returns a random decimal number between 0 and 32767. Cmd.exe generates this variable.SYSTEMDRIVESystem returns the drive containing the Windows root directory (i.e., the system root).SYSTEMROOTSystem returns the location of the Windows root directory.TEMP or TMPSystem and User return the default temporary directories for applications that are available to users who are currently logged on. Some applications require TEMP and others require TMP.TIMESystem returns the current time. This variable uses the same format as the time /t command. Cmd.exe generates this variable. For more information about the time command, see the Time command.USERDOMAINLocal returns the name of the domain that contains the user's account.USERNAMELocal returns the name of the user currently logged on.USERPROFILELocal returns the location of the profile for the current user.WINDIRSystem returns the location of the OS directory

To access these environment variables, you must place a percentage symbol (%) before and after the variable. For example,

echo %PROCESSOR_ARCHITECTURE%
x86 

will display the processor type (but still won't display Intel's ia64 platform). Some environment variables are available only in later OSs (e.g., %RANDOM% is not available in Windows NT 4.0). See also, Dick Lewis' more in-depth, " Environment Variable Commands ."

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish