其实很简单:
0,开始位置;
10,取字符的个数;
例如当前时间是:
日期是:
%date:~0,10%就是2008-05-29
%time:~0,2%就是14
%time:~3,2%就是13
如果我们做一个备份时就显得有些用处,可以把当时做备份文件用此命名,例如:
path c:\Program Files\WinRAR
rar a .\bak%date:~0,10%_%time:~0,2%%time:~3,2%.rar .\*.bak
del .\*.bak
备份DHCP:
@echo on
@echo Bakup DHCP config start…………
::备份dhcp文件
netsh dhcp server dump >d:\bakup\dhcp\dhcp_bak%date:~0,10%.txt /y
echo DHCP config backup complete!
echo off
备份DNS:
@echo Backup DNS config start…………
rem md d:\backup\dns
copy c:\windows\system32\dns\*.dns d:\backup\DNS /y
reg export HKLM\system\currentcontrolset\services\dns d:\backup\DNS\%date:~0,10%-1.reg /y
regedit /e d:\backup\dns\%date:~0,10%-2.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server"
@echo DNS config backup complete!
echo off
exit