Jump to content

run a file as other user


Recommended Posts

Hello,

It's loooong time I'm missing from this forum and my Autoit knowledge is heavily rusted.

I'm looking for a way to run (launch) an application as other user.

I do know that if I right-click an application icon while keeping Shift key pressed, i could select "run as other user", but i was looking for a more "elegant" way so I think it may be a way to do it with Autoit. 

If I know username and password of the other user there must be a way to do it automatically...

Any help would be appreciated

 

Link to comment
Share on other sites

I need some more help on this.

Running the following example I do have strange behaviour:

#include <AutoItConstants.au3>

Example("user01")
Example("user02")
Example("user03")


Func Example($uname)
    Local $sUserName = $uname
    Local $sPassword = "pw_is_always_the_same"

    ; Run chrome with the window maximized. chrome is run under the user previously specified.
    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", @SW_SHOWMAXIMIZED)

    ; Wait 10 seconds for the Chrome window to appear.
    WinWait("[CLASS:Chrome_WidgetWin_1]", "", 10)

    MouseMove(579,278,40)
    MouseClick($MOUSE_CLICK_LEFT)
    Sleep(2000)

    ; Close the Chrome process using the PID returned by RunAs.
    ProcessClose($iPID)
EndFunc   ;==>Example

I would like to run Chrome 3 times (or more)  as a different user, moving the mouse, closing the app, then do it again with different user.

User01 runs fine: the mouse does the job and the process closes.

user02 and user03 won't launch chrome anymore but the mouse keeps on moving and clicking, as programmed. It doesn't care if the window is open or not.

Also, when I try to run chrome manually as user01, most of the times it says that chrome did not close well, and asks me to restore previous state.

Why don't let me run chrome as other users? Why it only seems to work with first user?

Thanks in advance for any help

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...