I have discussed
environment variables in some detail for Windows XP on another page.
Many of the general considerations given there apply to Vista as
well and they will not be repeated here. However, there are some
changes and they will be outlined.
List of common preset environment
variables
The table below lists
the environment variables most usually encountered. I have omitted
some of the more technical ones, such as those that give information
about the CPU. Many of the variables in Vista are similar to those
in Windows XP but there are some that are new. Also the paths
associated with many have changed. Changes and additions are
indicated in red.
Table I. Some more common
predefined environment variables in Vista
| Variable |
Typical value (May vary,
depending on system) |
| %ALLUSERSPROFILE% |
C:\ProgramData |
| %APPDATA% |
C:\Users\(username}\AppData\Roaming |
| %CommonProgramFiles% |
C:\Program
Files\Common Files |
| %COMPUTERNAME% |
{computername} |
| %COMSPEC% |
C:\Windows\System32\cmd.exe |
| %HOMEDRIVE% |
C: |
| %HOMEPATH% |
\Users\{username} |
| %LOCALAPPDATA% |
C:\Users\{username}\AppData\Local |
| %PATH% |
C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem |
| %PATHEXT% |
.COM; .EXE; .BAT; .CMD; .VBS;
.VBE; .JS ; .WSF; .WSH; .MSC |
| %ProgramData% |
C:\ProgramData |
| %PROGRAMFILES% |
Directory containing program
files, usually
C:\Program Files
|
| %PROMPT% |
Code for current command
prompt format. Code is usually
$P$G
|
| %Public% |
C:\Users\Public |
| %SYSTEMDRIVE% |
The drive containing the
Windows XP root directory, usually C: |
| %SYSTEMROOT% |
The Windows XP root directory,
usually
C:\Windows
|
| %TEMP% and %TMP% |
C:\Users\{Username}\AppData\Local\Temp |
| %USERNAME% |
{username} |
| %USERPROFILE% |
C:\Users\{username} |
| %WINDIR% |
C:\Windows |
Vista has changed the
locations for many of the personal files and settings. For example,
there is no longer a "Documents and Settings" folder. Most of the XP
environment variables that referred to this folder are still in
Vista but involve the new "Users" folder. (As an aside: why does
Microsoft continue to use some folders whose names have spaces like
"Program Files"? It means that environment variables often have to
be put in quotation marks.) There are also four new environment
variables listed in Table I. These are %CommonProgramFiles%, %LocalAppdata%,
%ProgramData%, and %Public%
Dynamic environment variables
The so-called
predefined variables are generally unchanged during a login session
but there are also some dynamic variables whose value may change.
Some of these are listed in the next table. These are the same as in
Windows XP but are listed again for convenience.
Table II. Some dynamic
environment variables
| Variable |
Value |
| %DATE% |
Current date in the format
determined by the Date command |
| %TIME% |
Current time in the format
determined by the Time command |
| %CD% |
Current directory with its
full path |
| %ERRORLEVEL% |
Number defining exit status of
a previous command or program |
| %RANDOM% |
Random number between 0 and
32767 |