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
  • 19,460
  • 23
  • 103
  • 133
sara
  • 3,724
  • 9
  • 40
  • 70

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,349
  • 1
  • 16
  • 18
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
  • 24,114
  • 8
  • 78
  • 84
David R Tribble
  • 11,312
  • 4
  • 41
  • 50
  • 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