Windows关机/重新启动通知器提供延迟选项,类似于自动更新

我有一个Windows程序部署使用WPKG运行隐藏到用户,并可能需要重新启动有时。 为了防止用户失去工作,我想要一个带有消息的对话框,给login的用户提供延迟closures的选项。 这与自动更新的方式类似。

我已经看了许多closures实用程序给用户一个消息,但没有给他们一点控制,以延迟closures。

一个快速和肮脏的select将是使用Microsofts Sysinternals的PSTOOLS套件中的PSSHUTDOWN 。

其中一个可用的交换机是-c 。 它允许用户通过按“ 取消”button停止重启。

-c允许closures被交互式用户中止。

您可以将其设置为每隔X分钟循环,直到用户准备好重新启动计算机为止。


一个更好的方法来做到这一点将是写你自己的VBScript。 这可以提供一个时髦的对话框,例如, 。 如果他们点击“否”,那么在再次询问之前将会restX分钟。 这将是很容易写。

编辑:好吧,我很无聊,所以我给你做了脚本。 请享用。

 option explicit on error resume next Dim strComputer, intRebootChoice Dim objWMIService, objOperatingSystem Dim colOperatingSystems strComputer = "." do while 1>0 intRebootChoice = msgbox("OI, you, need to reboot. Choose No to be asked again 1 hour",308,"Reboot incoming") select case intRebootChoice case 6 Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems ObjOperatingSystem.Reboot(1) Next case 7 wscript.sleep(3600000) case else 'shenanigans' end select loop 

C:\ WINDOWS \ system32 \ shutdown.exe实用程序似乎为我工作。]

请尝试以下操作: shutdown -r -t 500 -c“开心用户信息”

编辑:自动更新重新启动消息更具有超时重新启动button的唠叨屏幕。 很容易重复这个代码,虽然你可能需要问这个在stackoverflow 🙂