Windows内置环境变量列表总结

一,Windows常见环境变量大全

二,Windows Environment Variables

一,Windows常见环境变量大全

 环境变量一般是指在操作系统中用来指定操作系统运行环境的一些参数,比如临时文件夹位置和系统文件夹位置等。这点有点类似于DOS时期的默认路径,当你运行某些程序时除了在当前文件夹中寻找外,还会到设置的默认路径中去查找。简单地说这里的“Path”就是一个变量,里面存储了一些常用命令所存放的目录路径。

 

作用

主要用在解决双系统的软件共用问题:通过系统变量而不是具体的对象来访问。

 

查看环境变量

1、cmd指令打开命令提示符窗口;

2、执行set指令,列出当前环境变量列表。

 

设置环境变量

1、我的电脑->属性->高级->环境变量;

2、通过注册表修改:用户变量在HKEY_CURRENT_USER\Environment;系统变量\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment。

3、命令行set指令:例如set PATH=%PATH%;d:\xxx。

%ALLUSERSPROFILE%=C:\Documents and Settings\All Users 列出所有用户profile文件位置
%APPDATA%=C:\Documents and Settings\xx\Application Data 列出应用程序数据的默认存放位置
%CD%=C:\Documents and Settings\xx 列出当前目录。
%CLIENTNAME%=Console 列出联接到终端服务会话时客户端的NETBIOS名。
%CMDCMDLINE% 列出启动当前cmd.exe 所使用的命令行。
%CMDEXTVERSION% 命令出当前命令处理程序扩展版本号。
%CommonProgramFiles%=C:\Program Files\Common Files 列出了常用文件的文件夹路径。
%COMPUTERNAME%=xx 列出了计算机名。
%ComSpec%=C:\WINDOWS\system32\cmd.exe  列出了可执行命令外壳 (命令处理程序)的路径。
%DATE% 列出当前日期。
%ERRORLEVEL% 列出了最近使用的命令的错误代码。
%HOMEDRIVE%=C: 列出用户主目录所在的驱动器盘符。
%HOMEPATH%=\Documents and Settings\xx 列出用户主目录的完整路径。
%HOMEDRIVE%%HOMEPATH%\桌面 桌面
%HOMEDRIVE%%HOMEPATH%\「开始」菜单 开始菜单
%INCLUDE%=D:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\ vc用户变量
%LIB%=D:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\ vc用户变量
%LOGONSERVER%=\\xx 列出有效的当前登录会话的域名控制器名。
%luapath%=F:\hero\bin lua用户变量
%LUA_DEV%=d:\Program Files\Lua\5.1 lua用户变量
%LUA_PATH%=;;d:\Program Files\Lua\5.1\lua\?.luac lua用户变量
%NUMBER_OF_PROCESSORS%=2 列出了计算机安装的处理器数。
%OS%=Windows_NT  列出操作系统的名字。(WindowsXP 和Windows2000 列为Windows_NT.)
%Path%=C:\WINDOWS\system32;C:\WINDOWS;d:\Program Files\Lua\5.1;d:\Program Files\Lua\5.1\clibs  列出了可执行文件的搜索路径。
%PATHEXT%=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1;.wlua;.lexe  列出操作系统认为可被执行的文件扩展名。
%PROCESSOR_ARCHITECTURE%=x86  列出了处理器的芯片架构。
%PROCESSOR_IDENTIFIER%=x86 Family 6 Model 15 Stepping 13, GenuineIntel  列出了处理器的描述。
%PROCESSOR_LEVEL%=6  列出了计算机的处理器的型号。
%PROCESSOR_REVISION%=0f0d 列出了处理器的修订号。
%ProgramFiles%=C:\Program Files  列出了ProgramFiles 文件夹的路径。应用程序的默认安装目录
%PROMPT%=$P$G  列出了当前命令解释器的命令提示设置。
%RANDOM% 列出界于0 和32767 之间的随机十进制数。
%SESSIONNAME%=Console 列出连接到终端服务会话时的连接和会话名。
%ssuser%=xx  vss用户变量
%SystemDrive%=C: 列出了Windows 启动目录所在驱动器。
%SystemRoot%=C:\WINDOWS  列出了Windows 启动目录的位置。
%TEMP%=C:\DOCUME~1\xx\LOCALS~1\Temp  列出了当前登录的用户可用应用程序的默认临时目录。
%TMP%=C:\DOCUME~1\xx\LOCALS~1\Temp  列出了当前登录的用户可用应用程序的默认临时目录。
%TIME%  列出当前时间。
%USERDOMAIN%=xx   列出了包含用户帐号的域的名字。
%USERNAME%=xx  列出当前登录的用户的名字。
%USERPROFILE%=C:\Documents and Settings\xx  列出当前用户Profile 文件位置。
%VS71COMNTOOLS%=D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\ vc用户变量
%VS90COMNTOOLS%=D:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\  vc用户变量
%windir%=C:\WINDOWS   列出操作系统目录的位置

二,Windows Environment Variables

Environment variables are mainly used within batch files, they can be created, modified and deleted for a session using the SET command. To make permanent changes, use SETX

Variables can be displayed using either SET or ECHO.

Variables have a percent sign on both sides: %ThisIsAVariable%
The variable name can include spaces, punctuation and mixed case: %_Another Ex.ample%
(This is unlike Parameter variables which only have one % sign and are always one character long: %A )

Standard (built-in) Environment Variables
Variable Volatile
(Read-Only)
Default value in Windows 7/10/2008 (assuming the system drive is C: )
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Users\{username}\AppData\Roaming
CD Y The current directory (string).
ClientName Y Terminal servers only – the ComputerName of a remote host.
CMDEXTVERSION Y The current Command Processor Extensions version number. (NT = “1”, Win2000+ = “2”.)
CMDCMDLINE Y The original command line that invoked the Command Processor.
CommonProgramFiles C:\Program Files\Common Files
COMMONPROGRAMFILES(x86) C:\Program Files (x86)\Common Files
COMPUTERNAME {computername}
COMSPEC C:\Windows\System32\cmd.exe or if running a 32 bit WOW – C:\Windows\SysWOW64\cmd.exe
DATE Y The current date using same region specific format as DATE.
ERRORLEVEL Y The current ERRORLEVEL value, automatically set when a program exits.
FPS_BROWSER_APP_PROFILE_STRING
FPS_BROWSER_USER_PROFILE_STRING
Internet Explorer
Default
These are undocumented variables for the Edge browser in Windows 10.
HighestNumaNodeNumber Y (hidden) The highest NUMA node number on this computer.
HOMEDRIVE Y C:
HOMEPATH Y \Users\{username}
LOCALAPPDATA C:\Users\{username}\AppData\Local
LOGONSERVER \\{domain_logon_server}
NUMBER_OF_PROCESSORS Y The Number of processors running on the machine.
OS Y Operating system on the user’s workstation.
PATH User and
System
C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths}
PATHEXT .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .MSC
The syntax is like the PATH variable – semicolon separators.
PROCESSOR_ARCHITECTURE Y AMD64/IA64/x86 This doesn’t tell you the architecture of the processor but only of the current process, so it returns “x86” for a 32 bit WOWprocess running on 64 bit Windows. See detecting OS 32/64 bit
PROCESSOR_ARCHITEW6432 =%ProgramFiles% (only available on 64 bit systems)
PROCESSOR_IDENTIFIER Y Processor ID of the user’s workstation.
PROCESSOR_LEVEL Y Processor level of the user’s workstation.
PROCESSOR_REVISION Y Processor version of the user’s workstation.
ProgramW6432 =%PROCESSOR_ARCHITECTURE% (only available on 64 bit systems)
ProgramData C:\ProgramData
ProgramFiles C:\Program Files or C:\Program Files (x86)
ProgramFiles(x86) 1 C:\Program Files (x86)
PROMPT Code for current command prompt format,usually $P$G
C:>
PSModulePath %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
Public C:\Users\Public
RANDOM Y A random integer number, anything from 0 to 32,767 (inclusive).
%SessionName% Terminal servers only – for a terminal server session, SessionName is a combination of the connection name, followed by #SessionNumber. For a console session, SessionName returns “Console”.
SYSTEMDRIVE C:
SYSTEMROOT By default, Windows is installed to C:\Windows but there’s no guarantee of that, Windows can be installed to a different folder, or a different drive letter.
systemroot is a read-only system variable that will resolve to the correct location.
NT 4.0, Windows 2000 and Windows NT 3.1 default to C:\WINNT
TEMP and TMP User Variable C:\Users\{Username}\AppData\Local\Temp
Under XP this was \{username}\Local Settings\Temp
TIME Y The current time using same format as TIME.
UserDnsDomain Y
User Variable
Set if a user is a logged on to a domain and returns the fully qualified DNS domain that the currently logged on user’s account belongs to.
USERDOMAIN {userdomain}
USERDOMAIN_roamingprofile The user domain for RDS or standard roaming profile paths. Windows 8/10/2012 (or Windows 7/2008 with Q2664408)
USERNAME {username}
USERPROFILE %SystemDrive%\Users\{username}
This is equivalent to the $HOME environment variable in Unix/Linux
WINDIR %WinDir% pre-dates Windows NT and seems to be superseded by %SystemRoot%
Set by default as windir=%SystemRoot%
%windir% is a regular variable and can be changed, which makes it less robust than %systemroot%

1 Only on 64 bit systems, is used to store 32 bit programs.

Unless stated otherwise, all the variables above are System variables

Environment variables are stored in the registry:

User Variables: HKEY_CURRENT_USER\Environment
System Variables: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

By default, files stored under Local Settings do not roam with a roaming profile.

Dynamic environment variables are read-only and are computed each time the variable is expanded. When all variables are listed with SET, these will not appear in the list. Do not attempt to directly SET a dynamic variable.

 参考来源

http://ss64.com/nt/syntax-variables.html

https://en.wikipedia.org/wiki/Environment_variable#Windows

http://www.cnblogs.com/yuohoo/archive/2012/07/31/2616887.html