当前位置: 移动技术网 > IT编程>网络>Dos/Bat > 编程用到的windows系统目录变量简写

编程用到的windows系统目录变量简写

2017年12月08日  | 移动技术网IT编程  | 我要评论
%allusersprofile% c:\documents and settings\all users %userprofile% c:\documents and s
%allusersprofile% c:\documents and settings\all users
%userprofile% c:\documents and settings\当前用户名
%homepath% c:\documents and settings\当前用户名
%systemroot% c:\windows
%windir% c:\windows
%comspec% c:\windows\system32\cmd.exe
%appdata% c:\documents and settings\当前用户名\application data
%allappdata% c:\documents and settings\all users\application data
%systemdrive% c:
%homedrive% c:
%temp% 和 %tmp% c:\documents and settings\当前用户名\local settings\temp
%programfiles% c:\program files
%commonprogramfiles% c:\program files\common files
docum~1 documents and settings
progra~1 program files

编程用的到
%allusersprofile% c:\documents and settings\all users
%userprofile% c:\documents and settings\当前用户名
%homepath% c:\documents and settings\当前用户名
%systemroot% c:\windows
%windir% c:\windows
%comspec% c:\windows\system32\cmd.exe
%appdata% c:\documents and settings\当前用户名\application data
%allappdata% c:\documents and settings\all users\application data
%systemdrive% c:
%homedrive% c:
%temp% 和 %tmp% c:\documents and settings\当前用户名\local settings\temp
%programfiles% c:\program files
%commonprogramfiles% c:\program files\common files
docum~1 documents and settings
progra~1 program files
%systemdrive%:windows系统所在磁盘分区,通常就是c盘的根目录
%systemroot%,%windir%:windows系统所在的目录,通常是c:\winows
%programfiles%:通常情况下是c:\program files
%commonprogramfiles%:公用文件目录,通常是c:\program files\common files
%userprofile%:当前账户的用户目录,通常是c:\documents and settings\当前用户名
%alluserprofile%:所有用户的用户目录,通常是c:\documents and settings\all user
%temp%,%tmp%:当前用户的临时文件目录,通常是c:\documents and settings\当前用户名\local settings\temp

所谓的windows系统目录简写环境变量,就是为一些常用且固定的windows系统目录的路径建立一个与之对应的相对简单的缩写,使之更容易输入或定位。

windows系统默认情况下都是安装在电脑c盘的windows目录下,但这并不是固定的,如果你的系统不是安装在这个目录下,那么程序想要定位你的某个系统目录的话,就需要使用到目录简写环境变量了。使用这些环境变量,程序员或系统管理员无需事先了?解你的系统安装位置,就能轻易的找到所要使用的系统目录路径。

下面,我就来为大家介绍一些常见的windows系统目录简写环境变量:
%systemdrive%
这代表的是windows系统所在磁盘分区,也就是windows系统所安装到的盘符根目录,通常就是c盘的根目录了。
%homedrive%
这和上面介绍的%systemdrive%的功能是一样的。
%systemroot%
它所指向的是windows系统所在的目录,通常就是c:\windows。
%windir%
和%systemroot%的功能相同,指向windows所在目录。
%programfiles%
指向program files的路径,通常情况下是c:\program files。
%commonprogramfiles%
指向公用文件(common files)目录,通常是c:\program files\common files。
%userprofile%
指向当前帐户的用户目录,通常是c:\documents and settings\当前用户名。
%homepath%
功能和上面的%userprofile%是一样的。
%allusersprofile%
指向所有用户的用户目录,通常是c:\documents and settings\all users。
%appdata%
指向当前用户的application data目录,通常是c:\documents and settings\当前用户名\application data。
很多文章都会介绍一个叫做%allappdata%的变量,说它是指向c:\documents and settings\all users\application data的,但其实这个变量并不能使用。
%temp%
它指向的是当前用户的临时文件目录,通常是c:\documents and settings\当前用户名\local settings\temp。
%tmp%
与%temp%的指向相同。
%comspec%
指向c:\windows\system32\cmd.exe,也就是命令提示符。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网