Sideoutfan Posted February 18, 2016 Share Posted February 18, 2016 I'm trying to understand how to have a message box pop up if RunAs credentials are incorrect so user knows they may have typed their username or password incorrectly. Please provide suggestions. Can I do it within a Case as seen below whether adding a function that is called or something else? I'm not seeing such an option for notification within the RunAs parameters. Case $Registry $Username = GUICtrlRead($UNI) $Password = GUICtrlRead($PWField) $Domain = GUICtrlRead($DomList) RunAs($Username, $Domain, $Password, $RUN_LOGON_PROFILE, "C:\Windows\regedit.exe") Thank you for any help. Link to comment Share on other sites More sharing options...
InunoTaishou Posted February 18, 2016 Share Posted February 18, 2016 RunAs will return a PID if the function is successful, 0 if it failed. You can throw your RunAs call in an If statement like this #include <MsgBoxConstants.au3> If (Not RunAs($Username, $Domain, $Password, $RUN_LOGON_PROFILE, "C:\Windows\regedit.exe")) Then MsgBox($IDOK, "Failed", "Failed to start regedit.exe as " & $Username & @CRLF & "Your credentials may be incorrect") EndIf Link to comment Share on other sites More sharing options...
Sideoutfan Posted February 18, 2016 Author Share Posted February 18, 2016 Wow InunoTaishou. Thank you so much! That is fantastic. I really appreciate your help. I don't know that I would have figured this out on my own as I am fairly new to AutoIT. I'm most grateful. Works perfectly! Link to comment Share on other sites More sharing options...
InunoTaishou Posted February 18, 2016 Share Posted February 18, 2016 Np, almost every solution is already in the help file or has been answered. And almost all AutoIt functions return some kind of value letting you know if the function succeeded or failed, most will set the error flag to true (@Error) if it fails as well. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now