1、指定进程被关闭,系统自动重启
strComputer = "."
Set wbemServices = Getobject("winmgmts:\\" & strComputer)
Set wbemObjectSet = wbemServices.execquery("select * from Win32_Process where caption='WinVNC.exe'")
Do While wbemobjectset.count <> 0
WScript.Sleep 10000
Set wbemObjectSet = wbemServices.execquery("select * from Win32_Process where caption='WinVNC.exe'")
Loop
DownFlag=6
set win32_OS=getobject("winmgmts:{(Shutdown)}//./root/cimv2").execQuery("select * from win32_operatingsystem where primary=true")
for each OS in win32_OS
Set WshShell = CreateObject("WScript.Shell")
Dim CloseTime,i
CloseTime = 10
For i = CloseTime To 1 Step - 1
WshShell.popup "由於VNC被關閉,系統即將重啟!",1,"警告!",0
Wscript.Sleep 10000
Next
OS.win32shutdown(DownFlag)
next
set win32_OS=nothing
将指定的进程设为开机启动,然后用计划任务运行该VBS文件,可以防止进程被结束。
评论