windows - windows批处理中自动回答输入提示

标签 windows batch-file

在 Windows 批处理中,我想启动一个提示用户输入的程序:

>someProgram.exe
> "Please enter "s" to start the program:
> 

我怎样才能自动将“y”输入传递给提示符,这样我就可以通过单击批处理来启动程序?

最佳答案

你想要这个:

echo y | [Command]

例如:echo y |程序.exe

"echo <answer> | <batch command>"

例如:del/P 命令选项将在删除文件之前提示用户确认。 因此,如果您在批处理脚本中使用此选项,则需要手动输入才能继续。 为避免这种手动输入,请在批处理脚本中使用命令“echo Y | del/P”来回答提示。

当通过批处理脚本调用控制台应用程序时,您可以尝试使用此 echo 命令将输入​​(例如:用户名和密码提示的答案)传递给控制台应用程序。

引用:http://thirutechie.blogspot.com/2009/10/how-to-auto-answer-prompts-in-windows.html

关于windows - windows批处理中自动回答输入提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40610241/

相关文章:

regex - Windows 批处理文件中的正则表达式

c# - 自动关闭RegSvr32提示

windows - 如何从批处理文件 (Windows) 向文本文件添加行号

windows - 如何在具有多个 IF 语句的 .bat 文件中使用 ELSE 语句?

windows - 在Windows 10上安装Grails

c++ - 提高C++应用程序启动速度的方法

python - 如何从扩展名为 .pyw 的 Python 脚本打印到标准输出?

c - Winsock recv() 没有收到任何数据 (C)

c++ - 开发使用 MS CryptoAPI 的 64 位应用程序

windows - 在 Batch 中终止进程并报告成功