Jump to content
Sign in to follow this  
DavidTunnell

WinWait for Windows Security prompt issue

Recommended Posts

DavidTunnell

I am trying to run a network location that prompts a password, enter a username and password login.

This is my code:

Run("C:\WINDOWS\system32\rundll32.exe shell32.dll,#61")
WinWait("[CLASS:#32770]")
ControlFocus("Run", "", "[CLASS:Edit]")
Send($SecureServerShare)
ControlClick("Run", "", "[CLASS:Button; INSTANCE:2]")
$WaitCheck = WinWait("Windows Security", "Remember my credentials", 60)
;MsgBox(0, "", "")
If ($WaitCheck <> 0) Then
     ControlFocus("Windows Security", "", "[CLASS:DirectUIHWND]")
     ControlFocus("Windows Security", "", "[CLASS:Edit; INSTANCE:1]")
     Send($SecureUserName)
     Sleep(500)
     ControlFocus("Windows Security", "", "[CLASS:Edit; INSTANCE:2]")
     Send($SecurePassword)
     Sleep(500)
     ControlClick("Windows Security", "", "[CLASS:Button; INSTANCE:2]")
EndIf

The user of the script may or may not already be logged in. This is the reason for the if statement. If it times out it's supposed to return a 0.

I believe the issue is with the wait check... I tried what I am showing above:

$WaitCheck = WinWait("Windows Security", "Remember my credentials", 60)

As well as:

$WaitCheck = WinWait("[CLASS:#32770]", "", 60)

Using the AutoIt Window info Utility this is correct.. it is however the same as run. How do I correctly wait for this window to popup (which typically takes 25 seconds)?

Edited by DavidTunnell

Share this post


Link to post
Share on other sites
Cravin

Maybe you could try a Do...Until loop?

Do
Sleep(250)
Until WinExists("[CLASS:#32770]") = 1
Edited by Cravin

Share this post


Link to post
Share on other sites
allSystemsGo

Why not map the drive within the script then un-map it on exit?

Share this post


Link to post
Share on other sites
Cravin

Yeah, that would also work better, depending on what you're trying to do.. taking that into consideration, you could use the  DriveMapAdd function with flag 8 (Prompts for authentication).. that way you don't have to hard code a password into your script

Edited by Cravin

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  

×