Using VBScript to Kill a Process in Windows

After listing a process, you may want to kill or terminate a process:

strComputer = "."
strProcess = "'iexplore.exe'"

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

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcess )

For Each objProcess in colProcess
	objProcess.Terminate()
	WScript.Echo "Killed Process: " & objProcess.Name & vbTab & objProcess.ProcessId
Next

Leave a Reply