4

I'm writing a batch file that launch an application.

app.exe

After the application is launched, I'm getting a list of options in the console, and the program waits for input, for example:

a: start session

b: end session

c: end

How do I make the batch type a?

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
sara
  • 3,824
  • 9
  • 43
  • 71

2 Answers2

2

First, make sure if the application supports command line arguments. For example, at your command prompt, type:

C:\> app.exe /?

or

C:\> app.exe -h

or

C:\> app.exe --help

If it doesn't, try using

echo a | app.exe
npclaudiu
  • 2,401
  • 1
  • 18
  • 19
2

Other than using echo as @npclaudiu suggested, you could also write the expected input to a text file and then have the app read the file:

app.exe <input.txt

This works if the app expects more than one line of input.

Lesmana
  • 25,663
  • 9
  • 82
  • 87
David R Tribble
  • 11,918
  • 5
  • 42
  • 52
  • Well, it works only for the first line. For example- I want to open session and to close it immediately, so I put a and b in the txt file. It opened the session for the a and then say error reading option for the sec. Any idea? – sara Jul 06 '11 at 06:48