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

我有一个使用WPKG部署的 Windows程序,该程序对用户隐藏,有时可能需要重启.为了防止用户丢失工作,我想要一个带有消息的对话框,为登录用户提供延迟关闭的选项.这类似于自动更新的方式.

我已经查看了大量的关闭实用程序,这些实用程序为用户提供了一条消息,但没有一个可以为他们提供一些控制来延迟关闭.

一个快速而肮脏的选择是从 Microsofts Sysinternals开始在 PSTOOLS套件中使用 PSSHUTDOWN.

其中一个可用的开关是-c.它允许用户通过按“取消”按钮停止重新启动.

-c Allows the shutdown to be aborted by the interactive user.

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

一个更简洁的方法是编写自己的VBscript.这可以提供一个时髦的对话框,例如,是和否.如果他们点击否,它会在再次询问之前睡眠X分钟.这很容易写.

编辑:嗯,我很无聊所以我为你制作了剧本.请享用.

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

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...