2016-10-10 205 views
3

我看到有一些与我的问题相关的主题,但缺少一些内容,我需要创建批重新启动计算机并发送弹出消息;我有这样的:带消息延迟的批量重启

@echo off 
cd c:\windows\system32 
shutdown -r -t 600 -c "Your machine you need to reboot in 5 minutes." -f 
exit 

不过,我需要更多的东西,我需要2分钟的提醒计算机重新启动之前,有一种方式,用户可停止或重新启动计算机之前,提出一个新的时间。

回答

1

你可以尝试这样的事情:

@echo off 
shutdown -r -t 600 -c "Your machine you need to reboot in 5 minutes." -f 
Call :AskQuestion 
exit 
::*********************************************************************** 
:AskQuestion 
(
    echo Set Ws = CreateObject("wscript.shell"^) 
    echo wscript.sleep 180000 
    echo Answ = MsgBox("Did you want to cancel the scheduled reboot of your the computer ?"_ 
    echo ,VbYesNo+VbQuestion,"Did you want to cancel the scheduled reboot of your the computer ?"^) 
    echo If Answ = VbYes then 
    echo  Return = Ws.Run("cmd /c Shutdown -a",0,True^) 
    echo Else 
    echo  wscript.Quit(1^) 
    echo End If 
)>"%tmp%\%~n0.vbs" 
Start "" "%tmp%\%~n0.vbs" 
2
@echo off 
shutdown -r -t 300 -c "Your machine you need to reboot in 5 minutes." 
Echo Press any key to cancel 
timeout /t 180 
Echo 2 mins to go 
timeout /t 9999 
shutdown /a 

对于一般的帮助。在命令提示符下键入Help。对于列出的每个命令类型help <command>(例如help dir)或<command> /?(例如dir /?)。