Jump to content

Recommended Posts

Posted

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

Posted (edited)

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

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
  • Recently Browsing   0 members

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