Jump to content

RunAs with message box


Recommended Posts

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

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

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...