[ACCEPTED]-How to terminate process using VBScript-kill

Accepted answer
Score: 18

The way I have gotten this to work in the 7 past is by using PsKill from Microsoft's SysInternals. PsKill 6 can terminate system processes and any processes 5 that are locked.

You need to download the 4 executable and place it in the same directory 3 as the script or add it's path in the WshShell.Exec 2 call. Here's your sample code changed to 1 use PsKill.

Const strComputer = "." 
Set WshShell = CreateObject("WScript.Shell")
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'Process.exe'")
For Each objProcess in colProcessList 
  WshShell.Exec "PSKill " & objProcess.ProcessId 
Score: 1

Try explicit assert debug privilege {impersonationLevel=impersonate,(debug)}:

Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate,(debug)}!\\.\root\CIMV2")
Set procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name='SearchIndexer.exe'", , 48)
For Each proc In procs


More Related questions