
批处理修改系统时间并自动还原
展开全部
@echo off
set /p newtime=请按时间格式输入要设置的时间(精确到秒),然后回车:
set /p stime=请输入要持续的秒数:
set /a stime=%stime%
set ott=%time%
time %newtime%
for /f "tokens=1-3 delims=:, " %%i in ("%ott%") do set /a oht=%%i&set /a omt=%%j&set /a ost=%%k
set /a ttst=%oht%*3600+%omt%*60+%ost%+%stime%
set /a nh=%ttst%/3600
set /a nm=(%ttst%-%nh%*3600)/60
set /a ns=%ttst%-%nh%*3600-%nm%*60
ping 127.1 -n %stime%
time %nh%:%nm%:%ns%
set /p newtime=请按时间格式输入要设置的时间(精确到秒),然后回车:
set /p stime=请输入要持续的秒数:
set /a stime=%stime%
set ott=%time%
time %newtime%
for /f "tokens=1-3 delims=:, " %%i in ("%ott%") do set /a oht=%%i&set /a omt=%%j&set /a ost=%%k
set /a ttst=%oht%*3600+%omt%*60+%ost%+%stime%
set /a nh=%ttst%/3600
set /a nm=(%ttst%-%nh%*3600)/60
set /a ns=%ttst%-%nh%*3600-%nm%*60
ping 127.1 -n %stime%
time %nh%:%nm%:%ns%
追问
先谢谢哈。能不能不弹框啊,设置好了之后双击自动就运行了。我看有人用这个命令date 2013/8/1,直接就把时间改成8月1日了,我只需要改系统日期。再帮帮忙啦
追答
@echo off
echo Set shell = Wscript.createobject^("wscript.shell"^)>0.vbs
echo a = shell.run ^("0.bat",0^)>>0.vbs
set /p newdate=输入要设置的日期后回车:
set /p stime=请输入要持续的秒数:
set today=%date:~0,10%
echo date %newdate%>0.bat
echo ping 127.1 -n %stime%>>0.bat
echo date %today%>>0.bat
echo del 0.bat,0.vbs>>0.bat
0.vbs
要是想完全不弹框,连设置日期、持续秒数也不要,用下面的:
@echo off
echo Set shell = Wscript.createobject^("wscript.shell"^)>0.vbs
echo a = shell.run ^("0.bat",0^)>>0.vbs
set today=%date:~0,10%
echo date 要设置的日期>0.bat
echo ping 127.1 -n 持续的秒数>>0.bat
echo date %today%>>0.bat
echo del 0.bat,0.vbs>>0.bat
0.vbs
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |