【问题标题】:Executing a .bat file with a parameter and reading the console output in C++执行带有参数的 .bat 文件并在 C++ 中读取控制台输出
【发布时间】:2014-02-27 14:58:14
【问题描述】:

我有一个需要执行的批处理文件,它有一个参数,如果我要自己运行这个脚本,我会打开 cmd 并编写

lexparser.bat texfile.txt

然后将输出打印到控制台。 我货比三家,发现了一些似乎正在执行文件的代码,但我似乎无法提取输出的数据,但我不确定这是否正确。

QString pathDocument = qApp->applicationDirPath()+ "/stanford/lexparser.bat";
long result = (long)ShellExecute(0, 0, reinterpret_cast<const WCHAR*>(pathDocument.utf16()), 0, 0, SW_NORMAL);

我使用 C++ 作为我的语言,我还使用 Qt 库来帮助我。 我的编程能力有限,所以任何帮助将不胜感激

【问题讨论】:

    标签: c++ qt batch-file shellexecute


    【解决方案1】:

    我建议使用QProcess 来做这件事。

    请参阅this question and its accepted answer 了解如何执行此操作的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-25
      相关资源
      最近更新 更多