关了窗口不会执行了,也没有定时执行命令的东西。
可以用ping命令给一个不可用地址发包设定等待恢回复时间30分钟 ping 1.1.1.1 -n 1 -w 1800000 > nul
也可以用vbs代码,wscript.sleep(但是这个和命令行放不到一个文件)
cmd下定时执行命令可以使用 at 命令 或者 schtasks命令。
at 语法:at +时间+运行程序
schtasks语法:schtasks /creat /tn 设定定时运行的名字 /tr “运行程序” /sc daily /st时间
例:
1、at 12:30 notepad(12:30时运行记事本)
2、at 19:30 calc(19:30时运行计算器)
3、schtasks /create /tn 定时运行 /tr "notepad" /sc daily /st 12:30(12:30时运行记事本)
4、schtasks /create /tn 定时运行 /tr "calc" /sc daily /st 19:30(19:30时运行计算器)