|
|
发表于 2024-12-10 10:22:11
|
显示全部楼层
本帖最后由 czjt1234 于 2024-12-10 10:32 编辑
- Option Explicit
- Dim oWMI, oFSO, oWshShell, oSWbemEventSource, s
- Const FILE = "C:\Program Files\abc\A.exe" '要监视的程序
- Set oWMI = GetObject("Winmgmts:\\.\Root\Cimv2")
- oWMI.Security_.Privileges.Add 19 'SeDebugPrivilege
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- Set oWshShell = CreateObject("WScript.Shell")
- s = "SELECT * FROM __InstanceModificationEvent WITHIN 1 " & _
- "WHERE TargetInstance ISA 'Win32_Process' " & _
- "AND TargetInstance.Name = '" & oFSO.GetFileName(FILE) & "' " & _
- "AND TargetInstance.Status <> 'OK'"
- Set oSWbemEventSource = oWMI.ExecNotificationQuery(s)
- Do
- Set s = oSWbemEventSource.NextEvent()
- s.TargetInstance.Terminate()
- oWshShell.Run """" & FILE & """"
- Loop
复制代码 vbs
不知道怎么模拟卡死的进程,所以未测试 |
|