Results 1 to 5 of 5

Thread: Input a password to dialog box after launching app through VB script

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Input a password to dialog box after launching app through VB script

    I have written a script that launches an application from my desktop. I have no knowledge in scripting, but was able to google around and have it done. However I am stuck at a point where I am not able to input the password in the dialog box that gets opened when I launch the app. Below is code :

    Dim exeName
    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")

    exeName = """Actual Application path"""

    call WshShell.Run (exeName, 1, true)
    WScript.Sleep(100)
    WshShell.AppActivate "TAE" '-- Please note that TAE is the name that appears on title bar of the app
    WScript.Sleep(100)

    'Passing the value password
    WSHShell.SendKeys "welcome124"

    'MOving to enter
    WSHShell.SendKeys "{TAB}"

    'Clicking enter to complete the screen
    WSHShell.SendKeys "{ENTER}"
    set WshShell=Nothing

    Application gets launched and I get a dialog box which already has the username and cursor is on the password text field. Nothing happens after that. Sometimes password gets entered in some other application that is open - like notepad

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Input a password to dialog box after launching app through VB script

    Hi manishkumarM,

    You're calling whshell.run method the wrong way for your purposes. Your script doesn't need to wait for the application to close so change "true" to "false":

    Code:
    call WshShell.Run (exeName, 1, false)
    Also, please use code tags. You can access these using the "#" button in the toolbar above a message you're about to post on the fourm.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: Input a password to dialog box after launching app through VB script

    Thanks for offering assistance . I now changed it as below

    Code:
    call WshShell.Run (exeName, 1, false)
    WScript.Sleep(25)
    
    WshShell.AppActivate "TAE"
    
    'Passing the value password
    WSHShell.SendKeys "welcome2"
        
    'MOving to enter
    WSHShell.SendKeys "{TAB}"
    
    'Clicking enter to complete the screen
    WSHShell.SendKeys "{ENTER}"
    Application dialog box opens up asking for password. Cursor is on the password text box. But nothing goes in as input.

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Input a password to dialog box after launching app through VB script

    That is odd, it works for me. Why did you change the waiting period to 25 milliseconds? Try increasing it and see if that helps.

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: Input a password to dialog box after launching app through VB script

    Perfect. It worked ... I checked the time it takes to open the app manually and increased the wait time accordingly . Thank you so much for your help ! You are a star ..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width