`
zzc1684
  • 浏览: 1191441 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

windows系统动态变量

阅读更多
系统动态变量
动态变量,顾名思义,变量是动态的,会跟据环境的不同,在你使用的时候他的值也是不同的。
%CD% 当前目录
%DATE% - 当前日期
%TIME% - 当前时间
%RANDOM% 得到一个十进制数字的随机数 (0 和 32767 之间的任意)
%ERRORLEVEL% 当前 ERRORLEVEL 数值
%CMDEXTVERSION% - 当前命令处理器的版本号
%CMDCMDLINE% - 启动命令处理器的原始命令行
实例1
@echo off  
echo the current fold is %cd%
echo the date is %date%
echo the time is %time%
echo the random number is %RANDOM%
echo the errorlevel is %ERRORLEVEL%
echo the version of cmd %CMDEXTVERSION%
echo the command to start cmd is %CMDCMDLINE%
pause
结果:
the current fold is G:\projects
the date is 04/15/2011 Fri
the time is 20:10:29.12
the random number is 14500
the errorlevel is 0
the version of cmd 2
the command to start cmd is cmd /c ""G:\projects\test2.bat" "
Press any key to continue . . .
注意动态变量只有在命令扩展名被启用的时候才有效。在XP中命令扩展名默认是启用的。
%USERPROFILE%-当前用户的个性化Documents and Settings路径。比如:C:\Documents and Settings\robin
%TEMP%%TMP%:当前用户的临时文件存放路径。它一般是简写形式,比如C:\Documents and Settings\robin\Local Settings简写成了:C:\DOCUME~1\robin\LOCALS~1\Temp .
%path%:文件的搜索路径,每个路径用分号隔开。我们通常在环境变量的设置中把%JAVA_HOME%加入到path里
%windir%windows的安装目录。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics