从 .net 应用程序触发命令提示符窗口的按键

问题描述 投票:0回答:1
  • 我有一个 .net 控制台应用程序 在 10 个线程上运行一个名为
    RunBatch()
    的方法。
  • 该方法创建一个进程对象 并调用 .bat 文件。
  • .bat 文件运行一个实例 名为 Lualatex 的工具 - 这是一个 将 .tex 文件转换为 .pdf 的 exe files- 并将其传递给 要转换的.tex 文件。 (例如, Lualatex.exe“F:ile1.tex”)
  • 有时该工具会发现一些错误 .tex 文件格式,因此它会报告 它在命令提示符窗口中运行 工具。
  • 该工具会一直保留,直到用户做出响应 单击 Enter 然后进入消息 该工具继续处理文件 过程。

我需要的是 - 如果适用 - 使 .net 应用程序自动响应此消息,而无需让工具等待用户手动完成。

.net exception command-line
1个回答
0
投票

在查看了命令行参考后,我终于找到了这个问题的解决方案。

我发现命令提示符可能会从键盘手动或从文件接收返回键,因此我创建了一个名为 input.txt 的文本文件,其中仅包含空行(通过从键盘按 Enter 键),然后这样运行批处理:

Lualatex.exe "F:\file1.tex" <input.txt

注意事项:< before the file path means that the inputs needed by the exe running will be provided from the file specified. Also notice that the file is in the same path as the exe.

© www.soinside.com 2019 - 2024. All rights reserved.