user2095405
user2095405

Reputation: 479

How to control .exe file with .bat file?

Hi I have program Program.exe which have some 3 parameters. And I am trying to control this program via .bat file. I can run this program with parameters without any problems, its easy. But if this program starts succesfully, then there are two choices what to do. For example if user type 'a' then this program writes on console 'hi'. If user types 'b' then program writes to console 'hello'. I want to somehow sent to this Program.exe only the 'a' choice after start. Unfortunaly I cant add another parameter. Does anyone know how to do it? So here is my very simple .bat file.

Program %1 %2 %3

and I tried to add this command to .bat file but it doesnt works.

echo a > Program

Thanks for help.

Upvotes: 0

Views: 2639

Answers (1)

ElektroStudios
ElektroStudios

Reputation: 20474

Try:

Echo a| Program %1 %2 %3

That is a known method for most CLI apps, but is not valid for all applications, if the pipe don't work for your app then forget to do it using native Batch and try a nircmd sendkey command or another CLI app to send keys.

Pipes: http://ss64.com/nt/syntax-redirection.html

NirCMD: http://www.nirsoft.net/utils/nircmd.html

Upvotes: 1

Related Questions