VBscript to kill 2 or more process in windows 2003

Just to share a sample script to kill multiple process in your windows 2000, XP or Vista

Option Explicit
Dim objWMIService, objProcess, colProcess
Dim xComputer, xProcessKill ,xProcessKill2,xProcessKill3
xComputer = "."
xProcessKill = "'taskmgr.exe'"
xProcessKill2 = "'notepad.exe'"
xProcessKill3 = "'iexplore.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& xComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill)
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill2)
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill3)
For Each objProcess in colProcess
objProcess.Terminate()
Next

Comments

Anonymous said…
Great ! Thank you very much, that's exactely what I'ved looking for and trying to do all afternoon :)

Popular posts from this blog

How to disable Trend Micro OfficeScan using cmd.

Fake torrent from www.YayMovies.com .. Beware !!! It is a Scam !!

Zishan Z1 firmware Update and Manual