A project I have been working on calls an external executable that I have little control over. It uses StandardOutput and StandardError which I can capture just fine from other similar things I’ve done. Unfortunately the program doesn’t take commandline input. It prompts. That’s where I can’t figure out how to read what it’s prompting for, how to send it what it’s prompting for, etc.
When you run the problem, it asks: “Please type in the path to the CSV files.”
Once you do this and press enter, it completes, then prompts: “Completed, Please press Enter.”
Then it exists.
I can’t figure out how to feed it the first item, then wait for the “completed prompt” to send it an “Enter” so it will exit and allow me to capture the StandardOutput and StandardError to log it and move on with my script.
Any ideas? I have been working with a chunk of code I have used in the past that looks like this:
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo $ProcessInfo.FileName = "ping.exe" $ProcessInfo.RedirectStandardError = $true $ProcessInfo.RedirectStandardOutput = $true $ProcessInfo.UseShellExecute = $false $ProcessInfo.Arguments = "localhost -t" $Process = New-Object System.Diagnostics.Process $Process.StartInfo = $ProcessInfo $Process.Start() | Out-Null $Process.WaitForExit() $output = $Process.StandardOutput.ReadToEnd() $output
That piece only works with a process that runs, then exits, but doesn’t require additional input. Has anyone worked with something like this and have any clues on how to proceed? Or am I stuck? Thanks!