René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

Default environment variables under windows

%ALLUSERSPROFILE%

Location of the All Users Profile, typically something like C:\Documents and Settings\All Users

%APPDATA%

Location where applications store their data.

%CD%

Current directory.

%CLIENTNAME%

%CMDCMDLINE%

The exact command line used to start the current cmd.exe.

%CMDEXTVERSION%

Version number of the current Command Processor Extensions.

%CommonProgramFiles%

%COMPUTERNAME%

The name of the computer.

%ComSpec%

The path to the command shell executable (for example: C:\WINDOWS\system32\cmd.exe)

%DATE%

The current date as formatted by the date /t command.

%ERRORLEVEL%

The error code of the most recently executed command.
A value different from zero usually indicates an error.

%FP_NO_HOST_CHECK%

%HOMEDRIVE%

The user's home directory's drive letter.

%HOMEPATH%

The path to the user's home directory (without %HOMEDRIVE).

%HOMESHARE%

The network path to the user's shared home directory.

%LOGONSERVER%

The name of the domain controller that validated the current logon session.

%NUMBER_OF_PROCESSORS%

The number of processors available.

%OS%

The name of the operating system (for example Windows_NT).

%PATH%

The paths separated by semicolons used to search executable files.

%PATHEXT%

List of file extensions that are considered to be executable.

%PROCESSOR_ARCHITECTURE%

The chip architecture of the processor. Possible values: x86 and IA64.

%PROCESSOR_IDENTFIER%

Description of the processor (for example: x86 Family 6 Model 9 Stepping 5, GenuineIntel).

%PROCESSOR_IDENTIFIER%

%PROCESSOR_LEVEL%

The model number of the processor (for example: 6).

%PROCESSOR_REVISION%

The revision number of the processor (for example: 0905).

%ProgramFiles%

%PROMPT%

The command prompt settings for the current interpreter.

%RANDOM%

A Random decimal number between 0 and 32767.

%SESSIONNAME%

%SystemDrive%

The drive containing the Windows XP root directory (for example: C:).

%SystemRoot%

The location of the Windows XP root directory (for example: C:\WINDOWS).

%TEMP% and %TMP%

The default temporary directories that are used by applications. Some applications require TEMP and others require TMP.

%TIME%

the current time as returned by time /t.

%USERDOMAIN%

The name of the domain that contains the user's account.

%USERNAME%

The name of the currently logged on user.

%USERPROFILE%

The profile for the current user, typically something like C:\Documents and Settings\Rene (for User Rene).

%windir%

The location of the system directory (for example C:\WINDOWS)

With enabled command extension

These registry keys specify if command extension is enabled: HKCU\Software\Microsoft\Command Processor\EnableExtensions and HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions. It can also be disabled when cmd is started:
C:>cmd /E:off
If command extension is enabled, the following environment variables are additionally available: CD, CMDEXTVERSION, DATE, ERRORLEVEL RANDOM and TIME.

Adding and changing environement variables

Values set in registry

The values for windows environment variables are set in the registry under \HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and under \HKCU\Environment. They can thus be changed with regedit.

Control panel

Control Panel->System->
Advanced tab, Environment Variables.
Starting with Vista, the panel can be displayed from the command line (cmd.exe) with a
rundll32 sysdm.cpl,EditEnvironmentVariables.

setx

Starting with Vista, environment variables can apparently be modified with setx on the command line (cmd.exe).