![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Cancel Process that is a System Task I'm using VBS trying to cancel a process who's user is SYSTEM. The code below work just fine for any process that I've started, but if I try one that has a user of SYSTEM it doesn't work. strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") For Each objProcess in colProcessList objProcess.Terminate() Next WSCript.Echo "Just killed process " _ & " on " & strComputer This is pretty standard code to do this, but it just does not seem to be working for the system users. Thanks for any suggestions. Rodney |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Cancel Process that is a System Task "Installer" <Installer@xxxxxx> wrote in message news:29729467-CD51-4EA5-AD1C-8D7B892CE174@xxxxxx Quote: > I'm using VBS trying to cancel a process who's user is SYSTEM. The code > below work just fine for any process that I've started, but if I try one > that > has a user of SYSTEM it doesn't work. > > strComputer = "." > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set colProcessList = objWMIService.ExecQuery _ > ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") > > For Each objProcess in colProcessList > objProcess.Terminate() > Next > WSCript.Echo "Just killed process " _ > & " on " & strComputer > > This is pretty standard code to do this, but it just does not seem to be > working for the system users. > > Thanks for any suggestions. > Rodney see a screen message that tells you the reason. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Cancel Process that is a System Task Yes, I have no problem with taskkill. My problem with using taskkill from the shell command is that it ignores my vbHide parameter and I get the pop-up cmd prompt. This looks really awful during an install so I was trying to get everything into vbscript. Thanks for the idea. "Pegasus (MVP)" wrote: Quote: > > "Installer" <Installer@xxxxxx> wrote in message > news:29729467-CD51-4EA5-AD1C-8D7B892CE174@xxxxxx Quote: > > I'm using VBS trying to cancel a process who's user is SYSTEM. The code > > below work just fine for any process that I've started, but if I try one > > that > > has a user of SYSTEM it doesn't work. > > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > > > Set colProcessList = objWMIService.ExecQuery _ > > ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") > > > > For Each objProcess in colProcessList > > objProcess.Terminate() > > Next > > WSCript.Echo "Just killed process " _ > > & " on " & strComputer > > > > This is pretty standard code to do this, but it just does not seem to be > > working for the system users. > > > > Thanks for any suggestions. > > Rodney > Can you kill the task with taskkill.exe? If you can't the you'll probably > see a screen message that tells you the reason. > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Cancel Process that is a System Task "Installer" <Installer@xxxxxx> wrote in message news:1D0FF693-FDCD-431B-9428-981DE417C8B0@xxxxxx Quote: > Yes, I have no problem with taskkill. My problem with using taskkill from > the shell command is that it ignores my vbHide parameter and I get the > pop-up > cmd prompt. This looks really awful during an install so I was trying to > get > everything into vbscript. > > Thanks for the idea. subsequently found that I could not terminate System tasks either when using your code. On the other hand I could use the "taskkill" work-around without getting a pop-up Command Prompt by running this code: Set ObjWshShell = WScript.CreateObject("WScript.Shell") ObjWshShell.Run "taskkill.exe /f /im MqrServerMon.exe", 0, False |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Cancel Process that is a System Task "Installer" wrote: Quote: > Yes, I have no problem with taskkill. My problem with using taskkill from > the shell command is that it ignores my vbHide parameter and I get the pop-up > cmd prompt. This looks really awful during an install so I was trying to get > everything into vbscript. > > Thanks for the idea. > > "Pegasus (MVP)" wrote: > Quote: > > > > "Installer" <Installer@xxxxxx> wrote in message > > news:29729467-CD51-4EA5-AD1C-8D7B892CE174@xxxxxx Quote: > > > I'm using VBS trying to cancel a process who's user is SYSTEM. The code > > > below work just fine for any process that I've started, but if I try one > > > that > > > has a user of SYSTEM it doesn't work. > > > > > > strComputer = "." > > > Set objWMIService = GetObject("winmgmts:" _ > > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > > > > > Set colProcessList = objWMIService.ExecQuery _ > > > ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") > > > > > > For Each objProcess in colProcessList > > > objProcess.Terminate() > > > Next > > > WSCript.Echo "Just killed process " _ > > > & " on " & strComputer > > > > > > This is pretty standard code to do this, but it just does not seem to be > > > working for the system users. > > > > > > Thanks for any suggestions. > > > Rodney > > Can you kill the task with taskkill.exe? If you can't the you'll probably > > see a screen message that tells you the reason. > > > > > > Your WMI code should work providing that you use the right privileges: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate, " _ & "(Debug)}!\\" _ & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process " _ & "Where Name = 'someprocess.exe'") For Each objProcess in colProcessList intRetVal = objProcess.Terminate() Next WSCript.Echo "Just killed process " _ & " on " & strComputer -- urkec |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Cancel Process that is a System Task "urkec" <urkec@xxxxxx> wrote in message news:6FC247B8-94DB-4E9B-A746-0DDF9031E5F6@xxxxxx Quote: > "Installer" wrote: > Quote: >> Yes, I have no problem with taskkill. My problem with using taskkill >> from >> the shell command is that it ignores my vbHide parameter and I get the >> pop-up >> cmd prompt. This looks really awful during an install so I was trying to >> get >> everything into vbscript. >> >> Thanks for the idea. >> >> "Pegasus (MVP)" wrote: >> Quote: >> > >> > "Installer" <Installer@xxxxxx> wrote in message >> > news:29729467-CD51-4EA5-AD1C-8D7B892CE174@xxxxxx >> > > I'm using VBS trying to cancel a process who's user is SYSTEM. The >> > > code >> > > below work just fine for any process that I've started, but if I try >> > > one >> > > that >> > > has a user of SYSTEM it doesn't work. >> > > >> > > strComputer = "." >> > > Set objWMIService = GetObject("winmgmts:" _ >> > > & "{impersonationLevel=impersonate}!\\" & strComputer & >> > > "\root\cimv2") >> > > >> > > Set colProcessList = objWMIService.ExecQuery _ >> > > ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") >> > > >> > > For Each objProcess in colProcessList >> > > objProcess.Terminate() >> > > Next >> > > WSCript.Echo "Just killed process " _ >> > > & " on " & strComputer >> > > >> > > This is pretty standard code to do this, but it just does not seem to >> > > be >> > > working for the system users. >> > > >> > > Thanks for any suggestions. >> > > Rodney >> > >> > Can you kill the task with taskkill.exe? If you can't the you'll >> > probably >> > see a screen message that tells you the reason. >> > >> > >> > > > Your WMI code should work providing that you use the right privileges: > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate, " _ > & "(Debug)}!\\" _ > & strComputer & "\root\cimv2") > > Set colProcessList = objWMIService.ExecQuery _ > ("Select * from Win32_Process " _ > & "Where Name = 'someprocess.exe'") > > For Each objProcess in colProcessList > intRetVal = objProcess.Terminate() > Next > WSCript.Echo "Just killed process " _ > & " on " & strComputer > > > -- > urkec qualifier, yet your version works. What exactly does (Debug) do? |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Cancel Process that is a System Task "Pegasus (MVP)" wrote: Quote: > AFAICS, the only difference between the OP's code and yours is the (Debug) > qualifier, yet your version works. What exactly does (Debug) do? This privilege (SE_DEBUG_PRIVILEGE) is required to kill other users's processes. You need to be an admin to be able to activate this privilege or this one have to be manually granted to a user with the security policy editor. The link below is very interesting (Specifically Table 6.8 : Privileges and descriptions). Hope this helps. -- Gilles LAURENT MVP Windows Server - Admin Frameworks http://glsft.free.fr |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Cancel Process that is a System Task "Pegasus (MVP)" wrote: Quote: > > "urkec" <urkec@xxxxxx> wrote in message > news:6FC247B8-94DB-4E9B-A746-0DDF9031E5F6@xxxxxx Quote: > > "Installer" wrote: > > Quote: > >> Yes, I have no problem with taskkill. My problem with using taskkill > >> from > >> the shell command is that it ignores my vbHide parameter and I get the > >> pop-up > >> cmd prompt. This looks really awful during an install so I was trying to > >> get > >> everything into vbscript. > >> > >> Thanks for the idea. > >> > >> "Pegasus (MVP)" wrote: > >> > >> > > >> > "Installer" <Installer@xxxxxx> wrote in message > >> > news:29729467-CD51-4EA5-AD1C-8D7B892CE174@xxxxxx > >> > > I'm using VBS trying to cancel a process who's user is SYSTEM. The > >> > > code > >> > > below work just fine for any process that I've started, but if I try > >> > > one > >> > > that > >> > > has a user of SYSTEM it doesn't work. > >> > > > >> > > strComputer = "." > >> > > Set objWMIService = GetObject("winmgmts:" _ > >> > > & "{impersonationLevel=impersonate}!\\" & strComputer & > >> > > "\root\cimv2") > >> > > > >> > > Set colProcessList = objWMIService.ExecQuery _ > >> > > ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") > >> > > > >> > > For Each objProcess in colProcessList > >> > > objProcess.Terminate() > >> > > Next > >> > > WSCript.Echo "Just killed process " _ > >> > > & " on " & strComputer > >> > > > >> > > This is pretty standard code to do this, but it just does not seem to > >> > > be > >> > > working for the system users. > >> > > > >> > > Thanks for any suggestions. > >> > > Rodney > >> > > >> > Can you kill the task with taskkill.exe? If you can't the you'll > >> > probably > >> > see a screen message that tells you the reason. > >> > > >> > > >> > > > > > Your WMI code should work providing that you use the right privileges: > > > > > > strComputer = "." > > > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate, " _ > > & "(Debug)}!\\" _ > > & strComputer & "\root\cimv2") > > > > Set colProcessList = objWMIService.ExecQuery _ > > ("Select * from Win32_Process " _ > > & "Where Name = 'someprocess.exe'") > > > > For Each objProcess in colProcessList > > intRetVal = objProcess.Terminate() > > Next > > WSCript.Echo "Just killed process " _ > > & " on " & strComputer > > > > > > -- > > urkec > AFAICS, the only difference between the OP's code and yours is the (Debug) > qualifier, yet your version works. What exactly does (Debug) do? > > > It is the short form (that you can use in the winmgmts: moniker) of SeDebugPrivilege. You can also enable it with objWMIService.Security_.Privileges.AddAsString("SeDebugPrivilege") or Const wbemPrivilegeDebug = 19 objWMIService.Security_.Privileges.Add(wbemPrivilegeDebug) See here for the complete list of privileges: http://msdn.microsoft.com/en-us/libr...58(VS.85).aspx -- urkec |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Cancel Process that is a System Task "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:%23Iq4oitTJHA.5860@xxxxxx Quote: > > "urkec" <urkec@xxxxxx> wrote in message > news:6FC247B8-94DB-4E9B-A746-0DDF9031E5F6@xxxxxx Quote: >> "Installer" wrote: >> Quote: >>> Yes, I have no problem with taskkill. My problem with using taskkill >>> from >>> the shell command is that it ignores my vbHide parameter and I get the >>> pop-up >>> cmd prompt. This looks really awful during an install so I was trying >>> to get >>> everything into vbscript. >>> >>> Thanks for the idea. >>> >>> "Pegasus (MVP)" wrote: >>> >>> > >>> > "Installer" <Installer@xxxxxx> wrote in message >>> > news:29729467-CD51-4EA5-AD1C-8D7B892CE174@xxxxxx >>> > > I'm using VBS trying to cancel a process who's user is SYSTEM. The >>> > > code >>> > > below work just fine for any process that I've started, but if I try >>> > > one >>> > > that >>> > > has a user of SYSTEM it doesn't work. >>> > > >>> > > strComputer = "." >>> > > Set objWMIService = GetObject("winmgmts:" _ >>> > > & "{impersonationLevel=impersonate}!\\" & strComputer & >>> > > "\root\cimv2") >>> > > >>> > > Set colProcessList = objWMIService.ExecQuery _ >>> > > ("Select * from Win32_Process Where Name = ""MqrServerMon.exe""") >>> > > >>> > > For Each objProcess in colProcessList >>> > > objProcess.Terminate() >>> > > Next >>> > > WSCript.Echo "Just killed process " _ >>> > > & " on " & strComputer >>> > > >>> > > This is pretty standard code to do this, but it just does not seem >>> > > to be >>> > > working for the system users. >>> > > >>> > > Thanks for any suggestions. >>> > > Rodney >>> > >>> > Can you kill the task with taskkill.exe? If you can't the you'll >>> > probably >>> > see a screen message that tells you the reason. >>> > >>> > >>> > >> >> Your WMI code should work providing that you use the right privileges: >> >> >> strComputer = "." >> >> Set objWMIService = GetObject("winmgmts:" _ >> & "{impersonationLevel=impersonate, " _ >> & "(Debug)}!\\" _ >> & strComputer & "\root\cimv2") >> >> Set colProcessList = objWMIService.ExecQuery _ >> ("Select * from Win32_Process " _ >> & "Where Name = 'someprocess.exe'") >> >> For Each objProcess in colProcessList >> intRetVal = objProcess.Terminate() >> Next >> WSCript.Echo "Just killed process " _ >> & " on " & strComputer >> >> >> -- >> urkec > AFAICS, the only difference between the OP's code and yours is the (Debug) > qualifier, yet your version works. What exactly does (Debug) do? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to write a script to process it as a task? | PowerShell | |||
| Cancel export certificate process in Windows Vista with IE 7 | Vista security | |||
| Windows Task Manager or Process Explorer? | General Discussion | |||
| Ending process in Task Manager doesn't end it | Vista performance & maintenance | |||
| System Idle Process | Vista performance & maintenance | |||