How to make a batch file that send application an input char

早过忘川 提交于 2019-12-01 05:29:18

问题


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?


回答1:


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.




回答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


来源:https://stackoverflow.com/questions/6583690/how-to-make-a-batch-file-that-send-application-an-input-char

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!