You are not logged in.

#1 01 Apr 2021 19:12

Rahul
Member
Registered: 18 May 2010
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 enetering of password and confirm password, considering I have the password.
Please help here. Powershell or vbscript is preferred solution.

Offline

#2 01 Apr 2021 20:53

Rahul
Member
Registered: 18 May 2010
Posts: 3

Re: Help needed to automate console input

Rahul wrote:

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 enetering of password and confirm password, considering I have the password.
Please help here. Powershell or vbscript is preferred solution.

Offline

#3 02 Apr 2021 09:10

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Help needed to automate console input

AutoIt with a suitable delay is probably the easiest way, though passing the password in plain text will not be secure.

https://www.autoitscript.com/site/autoit/

Offline

#4 04 Apr 2021 07:02

Manna5
Member
From: Cracow, Poland
Registered: 18 Mar 2021
Posts: 16
Website

Re: Help needed to automate console input

You can use SendKeys in VBScript:

objShell=CreateObject("WScript.Shell")
password=InputBox("Enter password:")
WScript.Sleep 100
objShell.SendKeys password
objShell.SendKeys "{ENTER}"
objShell.SendKeys password
objShell.SendKeys "{ENTER}"

It asks you for the password only once and "types" it two times. If you want it fully automated, you can even remove the input box and replace it with constant value.

Offline

Board footer

Powered by