Windows批处理中自动回答输入提示 [英] Automatically answer to input prompt in windows batch
问题描述
在Windows批处理中,我想启动一个程序来提示用户输入:
In a windows batch, I want to start a program that prompts the user for an input:
>someProgram.exe
> "Please enter "s" to start the program:
>
如何自动将"y"输入传递给提示符,以便我可以通过单击批处理来启动程序?
How can I automatically pass the "y" input to the prompt, such that I can start the program by just clicking the batch?
推荐答案
您要这样做:
echo y | [Command]
例如:echo y |程序.exe
Eg: echo y | program.exe
"echo <answer> | <batch command>"
Ex:在删除文件之前,del/P命令选项将提示用户确认. 因此,如果您在批处理脚本中使用此选项,则需要手动输入才能继续进行. 为了避免手动输入,请在批处理脚本中使用命令"echo Y | del/P"来回答提示.
Ex: The del /P command option will prompt for user's confirmation before deleting the file. So if you are using this option in your batch script, it requires manual input to proceed further. To avoid this manual input, use the command "echo Y | del /P " in your batch script to answer the prompt.
当通过批处理脚本调用输入时,您可以尝试使用此echo命令将输入(例如,用户名和密码提示的答案)传递到控制台应用程序.
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.
引用: http://thirutechie.blogspot.com/2009/10/how-to-auto-answer-prompts-in-windows.html
这篇关于Windows批处理中自动回答输入提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!