iDevelopSoftware

Simplicity and Clarity by Design

Environment Variables Provided by Windows Operating System

Microsoft assigns a type to each environment variable that is part of the environment block of a process. The possible types are System, User, Volatile and Process.

System : An environment variable that contains the same value for all processes running on the system, regardless of which user the process runs as. These are shared or global environment variables, and are defined in the system registry under the HKEY_LOCAL_MACHINE hive.

User : An environment variable that is specified for a particular user on the system. These are defined in the system registry as well, but are maintained under the HKEY_CURRENT_USER hive.

Volatile : An environment variable that is not persistent, and has a value that was assigned by the operating system based on some property of the system.

Process : An environment variable that is set only for a particular process. Often this would be set in the environment block by the parent process at the time the process is created. These are not persistent.

Additionally, the CMD.EXE command processor defines some dynamic environment variables that are assigned new values after each command is evaluated. These variables are volatile.

These tables were created by going through the on-line help for Windows 2000. I have listed all the volatile and dynamic environment variables I could find defined. There are probably more, and some of these may not be accurately documented.

Volatile Environment Variables
Name Description
ALLUSERSPROFILE Local – returns the location of the All Users Profile.
APPDATA Local – returns the location where applications store data by default.
COMPUTERNAME System – returns the name of the computer.
HOMESHARE System – 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.
LOGONSERVER Local – returns the name of the domain controller that validated the current logon session.
USERDOMAIN Local – returns the name of the domain that contains the user’s account.
USERNAME Local – returns the name of the user currently logged on.
USERPROFILE Local – returns the location of the profile for the current user.
NUMBER_OF_PROCESSORS Number of processors running on the machine.
PROCESSOR_ARCHITECTURE Processor type of the user’s workstation.
PROCESSOR_IDENTIFIER Processor ID of the user’s workstation.
PROCESSOR_LEVE Processor level of the user’s workstation.
PROCESSOR_REVISION Processor version of the user’s workstation.
OS Operating system on the user’s workstation.
COMSPEC Executable file for the command prompt (typically cmd.exe).
HOMEDRIVE Primary local drive (typically the C drive).
HOMEPATH Default directory for users (typically \users\default in Windows 2000).
PATH PATH environment variable.
PATHEXT Extensions for executable files (typically .com, .exe, .bat, or .cmd).
PROMPT Command prompt (typically $P$G).
SYSTEMDRIVE Local drive on which the system directory resides (typcially c:\).
SYSTEMROOT System directory (for example, c:\winnt). This is the same as WINDIR.
WINDIR System directory (for example, c:\winnt). This is the same as SYSTEMROOT.
TEMP Directory for storing temporary files (for example, c:\temp).
TMP Directory for storing temporary files (for example, c:\temp).
Expands to the current Command Processor Extensions version number.
Dynamic Environment Variables
Name Description
CD Expands to the current directory.
DATE Expands to the same output as typing DATE.
TIME Expands to the same output as typing TIME.
RANDOM Generates a random integer in the range of 0 – 32767.
ERRORLEVEL Expands to the current ERRORLEVEL.
CMDEXTVERSION
CMDCMDLINE Expands to the original command line that invoked the Command Processor.