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

Default environment variables under windows


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


Location where applications store their data.


Current directory.



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


Version number of the current Command Processor Extensions.



The name of the computer.


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


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


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



The user's home directory's drive letter.


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


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


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


The number of processors available.


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


The paths separated by semicolons used to search executable files.


List of file extensions that are considered to be executable.


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


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



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


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



The command prompt settings for the current interpreter.


A Random decimal number between 0 and 32767.



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


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.


the current time as returned by time /t.


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


The name of the currently logged on user.


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


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.


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