Results 1 to 5 of 5

Thread: Help needed to automate console input

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Help needed to automate console input

    Hello,

    Below is my command to perform one activity. It accepts few arguments which is fine and no issues there. But when we run that command in cmd, it asks for password and confirm password.
    I want to automate that password and confirm password part. How can I do that?

    Example:

    When we run below command in cmd -

    c:\Test\myscript.exe --arg1 --arg2 --config "c:\Temp\config.cfg" --confirm

    It shows below in same command prompt-

    Performing the script execution for ABCD.

    Enter password:

    Type again to confirm:


    What I need is, How can I automate this entering of password and confirm password, considering I have the password.
    Please help here. PowerShell or VBScript is preferred solution.

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,392

    Re: Help needed to automate console input

    What is in myscript.exe? Did you make an .exe out of a script? If so, what is in the script?

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: Help needed to automate console input

    Quote Originally Posted by jdc2000 View Post
    What is in myscript.exe? Did you make an .exe out of a script? If so, what is in the script?
    This is just an example I used. basically .exe is any program and we cannot modify that program since that is third party software.

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,392

    Re: Help needed to automate console input

    It sounds like what you are looking for is automated testing software. The links below might be useful:

    https://www.guru99.com/automated-testing-tools.html

    https://testguild.com/automation-testing-tools/

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: Help needed to automate console input

    Quote Originally Posted by jdc2000 View Post
    It sounds like what you are looking for is automated testing software. The links below might be useful:

    https://www.guru99.com/automated-testing-tools.html

    https://testguild.com/automation-testing-tools/


    Thanks. This is for automation for regular work not a testing software. I checked on internet and found this can be possible by VBscript or Powershell but not exact code. In VBScript we need to use sendkeys "{Enter}" something like that. I tried below code but still it is not working. WshShell.Run is working and it is even opening cmd and executing command but it is not entering the password.

    VBScript I am using -

    File::: myvbscript.vbs


    Dim WshShell

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

    WshShell.Run """c:\Test\myscript.exe"" --arg1 --arg2 --config ""C:\Test\config.cfg"" --confirm", 9
    WScript.Sleep 200
    input = Wscript.Arguments.Item(0)
    For i=LBound(1) To UBound(Len(input))
    Wscript.Sleep 200
    WshShell.SendKeys Mid(input, i, 1)
    echo input
    Next
    WshShell.SendKeys "{ENTER}"
    For i=LBound(1) To UBound(Len(input))
    Wscript.Sleep 200
    WshShell.SendKeys Mid(input, i, 1)
    Next
    Wscript.Sleep 200
    WshShell.SendKeys "{ENTER}"
    Wscript.Sleep 200

    This VBScript I am calling from batch file from command prompt. Batch file contents are -


    File::: mybatch.bat

    SET PWD = %~1
    cscript "c:\Test\myvbscript.vbs" %PWD%


    and batch file I am calling from command prompt as below -

    c:\Test\mybatch.bat "mypassword"

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