I am trying to run a batch file which requires user input "y/n" to do further action. I want to call this batch file for automation, as during automation argument yes or no need to be passed without user intervention, any idea how to achieve it ?
cmd /c setup.bat
Now if setup.bat
is run " yes or no " need to be selected to get the desired result
as now this setup.bat
is called during automation. Is there anyway to pass "yes" parameter as an input to setup.bat
?
Use below command line to automate "yes" answer by simulating
y
key press (will include theENTER
key).To automate "no" answer by simulating
n
key then ENTER` key.To automate "yes" answer by simulating "yes" key presses then
ENTER
key:To automate "no" answer by simulating "no" key presses then
ENTER
key:I guess the simplest solution here is using the pipe with cmd ( | : Reads the output from one command and writes it to the input of another command. Also known as a pipe) so for you its..
where Y will be your prompt input, the pressing of which you wish to automate
You can use stream operators like <. Write every expected answer one per line in a file (e.g. foi). Pass this file to the setup.bat using < operator: