Sign in to follow this  
Followers 0
rpaz

ProcessClose and Multiple Users

5 posts in this topic

Hi,

I don't know if this can be considered a bug or not but i found that ProcessClose can only terminate a process that belongs to the same user that is running the Autoit Script even if its a member of the Administrators group.

In my case i have a Script that needs full administrator rights. The script have #RequireAdmin on the begining and this works fine if a non-admin user (userX) runs the script, Windows XP will ask for the User/Pass of one Administrator to execute the task. My Script needs to restart a process that belongs to userX and i have found that ProcessClose fail to kill the process because the owner is userX and not the Administrator.

The solution i have found is to use DMI because where its possible to set SeDebugPrivilege privilege.

Func _ProcessKillAll($strProcessKill)
   local $objWMIService, $objProcess, $colProcess, $strComputer
   $strComputer = ".";replace with remote computer
       
   $objWMIService = Objget("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _ 
   & $strComputer & "\root\cimv2") 
   
  ; enable the SeDebugPrivilege privilege
   $objWMIService.Security_.privileges.addasstring("sedebugprivilege", true)
   
   $colProcess = $objWMIService.ExecQuery _
   ("Select * from Win32_Process Where Name = " & "'" & $strProcessKill & "'")
   For $objProcess in $colProcess
     $objProcess.Terminate(1)
   Next
EndFunc

Share this post


Link to post
Share on other sites



I don't think this is a bug, I believe ProcessClose has only ever worked on the current user.

Share this post


Link to post
Share on other sites

I don't think this is a bug, I believe ProcessClose has only ever worked on the current user.

It may not be a bug, but it sure is annoying if your logged in as admin and want to close processes not created in your session. :-P

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Hmm. This needs implemented. If you have the rights to do it AutoIt should let you do it. This is more of a feature request.

Share this post


Link to post
Share on other sites

The function given works wonderfully, I only have one question to the author or whomever has a better understanding of WMI...

Is there any way to use debug priveleges to do SuspendThread or SetPriority on processes that arent created by the current user?

- I attempted it but nothing I tried worked at all.

If not, how does Windows Task Manager do it? (since it's running under the current user)


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0