一个自动关闭计算机的脚本,可以自定义等待时间,用于希望能定时关闭计算机,但希望关机前得到提示并希望能取消这个操作的同学。 使用方法:把下面的代码拷贝粘贴到记事本,并保存为扩展名为Vbs的文件,然后在windows自带的计划任务里面定制即可。
附:脚本 'Create by iLoug@ROR set wshshell = CreateObject("WScript.Shell") timeout = 20 'Time Out 可以自己定义 ask = "系统将在 " & timeout & " 秒钟后将关机!" title = "自动关机" constants = vbExclamation + vbOkCancel result = wshshell.Popup(ask, timeout, title, constants) if result = vbCancel then elseif result = true then Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems ObjOperatingSystem.Win32Shutdown(8) Next end if
|