0

I am trying to automate one process which involves giving interactive input to a .exe utility. It expects the user-input for each step. I wanted to give all those values at single time while giving that command only. For eg: ./test.exe 8\n1\n0 etc. I have tried multiple ways to give input to the 'test.exe' utility like 8\n1\n0 | ./test.exe and 8,1,2 | ./test.exe. None of these worked. Any help how to pass these options 8,1,2 to the interactive utility test.exe in single line so that it will be helpful for my automation

newbie
  • 1,282
  • 3
  • 20
  • 43
  • Possible duplicate of [powershell sending multiple parameter to a external command](http://stackoverflow.com/questions/2137092/powershell-sending-multiple-parameter-to-a-external-command) – iRon Oct 18 '16 at 14:31

2 Answers2

0

There is no set way to automate a 3rd party program with Powershell. Not all utilities even offer the ability to do so.

  1. I'd look in the utility documentation for any switches.

  2. Try the following to see if you can get any built in help: test.exe -h, test.exe /h, test.exe /?, test.exe -?

  3. use the sysinternals strings utility to try and find anything that look like command line switches inside the exe that you can take advantage of. https://technet.microsoft.com/en-us/sysinternals/strings.aspx?f=255&MSPPError=-2147217396

Jim Moyle
  • 637
  • 4
  • 11
0

The answer depends entirely on how your executable works.

If the executable reads from standard input, you can redirect input to it as follows (PowerShell):

PS C:\> 8,1,2 | .\test.exe

This won't work if the executable doesn't read from standard input or if it clears the console input buffer.

The executable may also let you provide command-line arguments that specify the needed input, but this depends on the executable.

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62
  • Thanks Bill. That executable is not accepting any type of input given in command line. Looks like the exe will not accept input from command line or any arguments. Can we automate it by somehow sending input to this utility whenever it prompts for the option? – newbie Oct 19 '16 at 09:15
  • No, not using normal means. You will need to ask the author and/or experiment. If the executable is designed to prohibit automation, then there is probably not a lot you can do. – Bill_Stewart Oct 19 '16 at 14:22