尝试使用批处理将输入写入 运行 控制台应用程序时出错

Error while trying to write inputs to running console app with a batch

我有一个要用批处理文件执行的 exe 文件。

exe文件是第三方控制台应用程序,会提示输入三次。

所以我想用空行填充,someText和someOtherText

(echo. echo someText echo someOtherText) | call config.exe remove

但是我收到这个错误:

Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.

可能是什么问题,请至少告知搜索方向?

即使尝试执行更简单的命令,我也会遇到同样的错误:

echo. | call config.exe remove

您的 config.exe 根本不接受重定向。它需要真正的控制台缓冲区。

  1. 如果您想自动化它,您可以创建另一个控制台应用程序,它将
  1. 另一个更简单的选项是 ConEmu terminal (I'm the author). There is GuiMacro scripting,它可以很容易地从控制台使用。所以你可以从你的提示中 运行 或包装在批处理文件中(ConEmu 中的 运行):

    ConEmuC.exe -GuiMacro 打印“\nsomeText\nsome 其他 Text\n” & config.exe 删除