Windows平台上的环境变量

Windows XP中比较常见的预定义环境变量

===========================

Variable

Typical value (May vary, depending on system)

%ALLUSERSPROFILE%

C:\Documents and Settings\All Users

%APPDATA%

C:\Documents and Settings\{username}\Application Data

%COMPUTERNAME%

{computername}

%COMSPEC%

C:\Windows\System32\cmd.exe

%HOMEDRIVE%

C:

%HOMEPATH%

\Documents and Settings\{username}

%PATH%

C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

%PATHEXT%

.COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH

%PROGRAMFILES%

Directory containing program files, usually C:\Program Files

%PROMPT%

Code for current command prompt format. Code is usually $P$G

%SYSTEMDRIVE%

The drive containing the Windows XP root directory, usually C:

%SYSTEMROOT%

The Windows XP root directory, usually C:\Windows

%TEMP% and %TMP%

C:\DOCUME~1\{username}\LOCALS~1\Temp

%USERNAME%

{username}

%USERPROFILE%

C:\Documents and Settings\{username}

%WINDIR%

C:\Windows

一些动态的环境变量

===========================

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

Windows Vista/ 7 中常见的预定义环境变量

============================

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%

Varies. Includes 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

%ProgramFiles(x86)%

In 64-bit systems, directory containing 32-bit programs. Usually C:\Program Files (x86)

%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

资料来源:

Environment Variables in Windows XP

http://vlaurie.com/computers2/Articles/environment.htm

Environment Variables in Windows Vista and Windows 7

http://vlaurie.com/computers2/Articles/environment-variables-windows-vista-7.htm

原文地址:https://www.cnblogs.com/awpatp/p/1682662.html