第二个:- a = "aaa.exe"
- b = "bbb.exe"
- c = "ccc.exe"
-
- 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(a) Then
- KillProcess(b)
- KillProcess(c)
- End If
- Loop
-
-
-
- Sub KillProcess(sProcessName)
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
-
- Set colProcessList = objWMIService.ExecQuery _
- ("Select * from Win32_Process Where Name = '" & sProcessName & "'")
-
- For Each objProcess in colProcessList
- objProcess.Terminate()
- Next
- End Sub
复制代码
[ 本帖最后由 rat 于 2008-10-21 12:53 编辑 ] |