检测到explorer.exe进程被结束则立马关机- ' & start wscript -vbs "%~f0" & goto :eof
-
- MonitorProcess "explorer.exe"
-
-
-
- Sub MonitorProcess(strProcessName)
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- Set colMonitoredProcesses = objWMIService. _
- ExecNotificationQuery("select * from __instancedeletionevent " _
- & "within 1 where TargetInstance isa 'Win32_Process'")
- i = 0
-
- Do While i = 0
- Set objLatestProcess = colMonitoredProcesses.NextEvent
- If LCase(objLatestProcess.TargetInstance.Name) = LCase(strProcessName) Then
- 'CreateProcess strProcessName
- Shutdown
- End If
- Loop
- End Sub
-
- Sub CreateProcess(strProcessName)
- Set objWsh = CreateObject("WScript.Shell")
- objWsh.Run strProcessName
- Set objWsh = Nothing
- End Sub
-
- Sub Shutdown()
- strComputer = "."
- Set objWMIService = GetObject _
- ("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
- strComputer & "\root\cimv2")
-
- Set colOperatingSystems = objWMIService.ExecQuery _
- ("Select * from Win32_OperatingSystem")
-
- For Each objOperatingSystem in colOperatingSystems
- objOperatingSystem.Win32Shutdown(1)
- Next
- End Sub
复制代码
[ 本帖最后由 rat 于 2008-10-23 14:12 编辑 ] |