Reputation: 9625
I have an InputPromptAutomation.exe
that prompts for a user input when started and closes if the user input is s
:
C:\>AutomateInputPrompt\InputPromptAutomation.exe
Input 's' to stop the application:
s
C:\>
My Problem: I want to automate the startup of the .exe, such that I can start it by double-clicking a StartInputPrompt.bat
. How can I automatically pass the s
input, such that InputPromptAutomation.exe
starts AND exits upon executing StartInputPrompt.bat
?
Upvotes: 0
Views: 4351
Reputation:
echo s | AutomateInputPrompt\InputPromptAutomation.exe
Here's an example of piping Dir into a new CMD instance
Echo dir | cmd /k
Put S then Enter in a file.
AutomateInputPrompt\InputPromptAutomation.exe < file.txt
Here's an example of doing a dir
then a Type c:\windows\win.ini
File.txt (remember to press enter after the last line). This IS NOT a batch file (even though it is identical to one because I'm use CMD as a sample program).
dir
type c:\windows\win.ini
Then type
cmd /k < file.txt
This assumes the program is reading from StdIn, as most, but not all console programs do. EG when you see Press any key to continue
the program is NOT reading stdin.
Start is an internal command name. Do not name batch files start
as it will cause problems under some circumstances.
Upvotes: 1