|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Stopping Processes - Permission Errors
I need to stop a set of processes periodically. The snippet of code that I'm
using to try and kill the processes is: Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & cComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcessName & "'") For Each objProcess in colProcessList RetVal = objProcess.Terminate() I am an administrator on the server. When I try to run the script, it will kill some of the desired processes, but others I get permission denied. I can go into Task Manager and kill the processes with no problem. Any ideas on what I'm doing wrong? Thanks, Marty Martypi wrote:
Show quote > I need to stop a set of processes periodically. The snippet of code that I'm See if taking the debug priviledge helps.> using to try and kill the processes is: > > Set objWMIService = GetObject("winmgmts:" & > "{impersonationLevel=impersonate}!\\" & cComputer & "\root\cimv2") > Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process > Where Name = '" & strProcessName & "'") > For Each objProcess in colProcessList > RetVal = objProcess.Terminate() > > I am an administrator on the server. When I try to run the script, it will > kill some of the desired processes, but others I get permission denied. I > can go into Task Manager and kill the processes with no problem. > > Any ideas on what I'm doing wrong? Hi, Change "{impersonationLevel=impersonate}!\\" to "{impersonationLevel=impersonate,(Debug)}!\\" -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx |
|||||||||||||||||||||||