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的安装目录。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值