Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strProcessKill = "'ProcessName.exe'"
Set objWMIService = GetObject("winmgmts:root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WScript.Quit
Monday, 29 August 2011
VBScript to Terminate Process
Subscribe to:
Post Comments (Atom)
thanks ... I need to kill multiple processes with a single script.
ReplyDeleteis it possible?
Yes you can do it. run the code multiple timnes within a single script
ReplyDeleteHello,
ReplyDeleteI'm sorry I didn't understand ... you give an example ..
that is, for example, I just add the following lines in the script?
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strProcessKill = "'WinRAR.exe'"
strProcessKill = "'notepad.exe'"
strProcessKill = "'IEXPLORE.exe'"
Set objWMIService = GetObject("winmgmts:root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WScript.Quit
thanks again....