How do I read input from the console in a batch file? What I am trying to achieve is the functionality of scanf in C. How can I do the same in a batch file?
To avoid this manual input, use the command "echo Y | del /P " in your batch script to answer the prompt. You can try this echo command to pass input (ex: answer for username and password prompts) to your console application, when it is invoked through batch script.
In the batch script, you can get the value of any argument using a % followed by its numerical position on the command line. The first item passed is always %1 the second item is always %2 and so on. If you require all arguments, then you can simply use %* in a batch script.
batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.
The code snippet in the linked proposed duplicate reads user input.
ECHO A current build of Test Harness exists. set /p delBuild=Delete preexisting build [y/n]?:
The user can type as many letters as they want, and it will go into the delBuild variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With