I'm trying to terminate a process on my local PC using WMI's
.ProcessTerminate method. It's returning a value of 2 ("Access Denied"). I
can kill the same process from Task Manager without difficulty.

I searched MSDN for this situation and came up with the following page:
"Terminate Method of the Win32_Process Class"
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/terminate_method_in_class_win32_process.asp).

This page mentions enabling the SeDebugPrivilege privilege through VBScript
to get around this error; however, the the VBScript code that would
illustrate how to enable the SeDebugPrivilege privilege seems to be missing
from the page! Any idea where this--or similar--code can be found?

Re: Terminating a script / Content missing from MSDN page by JHP

JHP
Thu Dec 29 11:42:44 CST 2005

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/executing_privileged_operations_using_vbscript.asp

"Chris" <cwaters@newsgroup.nospam> wrote in message
news:0EEA2839-01D6-4FA7-AD9D-C5E1222C8676@microsoft.com...
> I'm trying to terminate a process on my local PC using WMI's
> .ProcessTerminate method. It's returning a value of 2 ("Access Denied"). I
> can kill the same process from Task Manager without difficulty.
>
> I searched MSDN for this situation and came up with the following page:
> "Terminate Method of the Win32_Process Class"
> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/terminate_method_in_class_win32_process.asp).
>
> This page mentions enabling the SeDebugPrivilege privilege through
> VBScript
> to get around this error; however, the the VBScript code that would
> illustrate how to enable the SeDebugPrivilege privilege seems to be
> missing
> from the page! Any idea where this--or similar--code can be found?



Re: Terminating a script / Content missing from MSDN page by cwaters

cwaters
Thu Dec 29 12:00:04 CST 2005

Thanks. I had seen that page, but wasn't sure of the significance of the
'debug privilege'. Is that privilege typically necessary to kill a process
that can't be killed otherwise?

Re: Terminating a script / Content missing from MSDN page by JHP

JHP
Thu Dec 29 12:25:30 CST 2005

Try this instead:

Option Explicit

Dim strComputer, strProcess, objWSH
Const WindowStyle = 0
Const WaitOnReturn = True

strComputer = "XXXXXXX"
strProcess = "XXXXX.exe"
Set objWSH = CreateObject("WScript.Shell")
objWSH.Run "TaskKill /s " & strComputer & " /im " & strProcess & " /f",
WindowStyle, WaitOnReturn
Set objWSH = Nothing

"Chris" <cwaters@newsgroup.nospam> wrote in message
news:EAB3962B-83DC-484E-8FA5-9CD3928A199A@microsoft.com...
> Thanks. I had seen that page, but wasn't sure of the significance of the
> 'debug privilege'. Is that privilege typically necessary to kill a process
> that can't be killed otherwise?