Option Explicit
Dim objWMIService,objProcess, objProcess1, colProcess, strProcess,strProcess1
Dim xComputer,Flag
strProcess = "'notepad.exe'"
strProcess1 = "'cmd.exe'"
xComputer = "."
Dim objWMIService,objProcess, objProcess1, colProcess, strProcess,strProcess1
Dim xComputer,Flag
strProcess = "'notepad.exe'"
strProcess1 = "'cmd.exe'"
xComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& xComputer & "\root\cimv2")
& "{impersonationLevel=impersonate}!\\" _
& xComputer & "\root\cimv2")
Do
Flag = 0
WScript.Sleep 60000
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcess)
For Each objProcess in colProcess
If objProcess.Name = strProcess then
objProcess.Terminate()
Flag=1
End If
Next
Loop Until Flag = 1
Flag = 0
WScript.Sleep 60000
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcess)
For Each objProcess in colProcess
If objProcess.Name = strProcess then
objProcess.Terminate()
Flag=1
End If
Next
Loop Until Flag = 1
Thanks for your help
ReplyDelete