Sort of need some help, i have found the script below, all well, its a good script, got it working no problem, what if i want to make the script kill 2 processes?
The script is:
Code:
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'calc.exe'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WScript.Quit
Many Many Many thanks in advance!
Last edited by Nico; 01-29-07 at 09:36 AM.
Reason: Please use [code] wrappers when posting code.
I am not a coder, i picked this code up when i was looking through google and found it really interesting.
Is it possible for you to insert the function? I have looked through google but seems to be more then 1 function, i tried to put one it but it didn't work :|
private sub KillProcess(strProcessKill as string)
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
end sub
then you call
KillProcess("calc.exe")
KillProcess("winword.exe")
WScript.Quit
and you've killed 2 processes
warning the above code in untested and written on the fly and is used to convey the idea of how to do it not the code that will do it
__________________
Definition of a Beginner, Someone who doesn't know the rules.
Definition of an Expert, Someone who knows when to ignore the rules.
Last edited by Nico; 01-29-07 at 09:36 AM.
Reason: Please use [code] wrappers when posting code.