Automate sending username and pw to an executeable

Hello,

I have a command line executable that connects to an API. In order to login i have to run the configure command at which time it prompts for user and then pw. It does now allow arguments to pass in. I tried running this script pilfered from various searches, but it stops after the Start-Process line and waits at the first prompt.

I call this from ssis execute process command that calls powershell.exe and passes the argument ExecutionPolicy Bypass -File “D:\ConfigureCredentials.ps1”

Contents of ConfigureCredentials.ps1":

$executablePath = “D:\acoms-cli.exe”
$username = “laksjdfhalsdjkfh”
$password = “alsdkfjhalsdfjkhaslkdfhalskdjfh”
$wshell = New-Object -ComObject WScript.Shell
$arg = “configure”
Start-Process -FilePath $executablePath -Argument $arg -NoNewWindow -Wait
Start-Sleep -Seconds 3
$wshell.SendKeys($username)
$wshell.SendKeys(“{ENTER}”)
Start-Sleep -Seconds 3
$wshell.SendKeys($password)
$wshell.SendKeys(“{ENTER}”)

any input or a different/better way of doing it is appreciated.

Thanks,

-Tim

Sorry, I dont have an answer for you. However, typically, when you use the approach you are taking, before sending the keys, you need to “Activate” the app using the AppActivate method. Here is some info on that.

Hi, welcome to the forum :wave:

Firstly, when posting code in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working).

You’re passing the -Wait parameter to Start-Process so the script won’t continue until acoms-cli.exe exits.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.