Jump to content
Sign in to follow this  
tonya123

Run as a different user

Recommended Posts

Hi,

I am very new to AutoIT so I am sorry for my ignorance.

I need to run a registry file prompting me for network account credentials (I.E. if you Shift+Right click a file and Run as a different User).

Is there anything for me to do this? Can anyone help point me in the right direction?

I have googled this to death with no joy :(

Cheers

Share this post


Link to post
Share on other sites

You can build a small GUI that prompts for it or use two Input Boxes.

Here's a GUI example:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Opt("GUIOnEventMode", 1)
$fLogin = GUICreate("Enter Credentials", 450, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$lText = GUICtrlCreateLabel("Please enter username and password", 45, 16, 340, 28, $SS_CENTER)
$iCredsUser = GUICtrlCreateInput("", 120, 55, 265, 20)
$iCredsPass = GUICtrlCreateInput("", 120, 85, 265, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
$lUser = GUICtrlCreateLabel("Username:", 10, 55, 95, 20, $SS_RIGHT)
$lPass = GUICtrlCreateLabel("Password:", 10, 85, 95, 20, $SS_RIGHT)
$bRun = GUICtrlCreateButton("Run", 16, 160, 100, 30)
$bCancel = GUICtrlCreateButton("Cancel", 317, 160, 100, 30)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func _Exit()
    GUIDelete($fLogin)
    Exit
EndFunc   ;==>_Exit

Users are usually prompted for credentials when running something that requires administrative access anyhow, have you tried #requireadmin?

Edited by blckpythn

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  

×
×
  • Create New...