LGG
LGG

Reputation: 538

invoking an executable on powershell and then type commands

I am trying to call a executable file as follows

.\test_use.exe

then I press the return key to get a interface like

"Enter a value between 1 and 5"

I type 4 and get some details. Is there a way to automate it via powershell. I tried passing

.\test_use.exe 4

But it does not work. I also tried

$input = "4"
Invoke-command ".\test_use.exe" -InputObject $input

I get the following error

Invoke-command: Parameter cannot be resolved using the specified named characters

Does anyone have any pointers ?? Will it be easier to do this in batch file and store the output in a text file?

Upvotes: 0

Views: 112

Answers (1)

unclemeat
unclemeat

Reputation: 5207

In batch you might be able to do the following:

(echo 4) | test_use.exe

See this question - how to pass input to .exe in batch file?

Upvotes: 1

Related Questions