【问题标题】:Node js can I get the exit code from the windows command line app written in C++? [duplicate]Node js 我可以从用 C++ 编写的 Windows 命令行应用程序中获取退出代码吗? [复制]
【发布时间】:2017-11-18 22:38:04
【问题描述】:

我有一个小实用程序 - 一个用 C++ 编写的 Windows 可执行文件,它返回 0 或 1 作为其退出代码。 我可以从 Node js 运行这个 C++ 可执行文件并在那里传递命令行参数。 有什么方法可以读取 Node js 中命令行应用程序的退出代码?

【问题讨论】:

    标签: c++ node.js windows command-line


    【解决方案1】:

    是的,您将它作为关闭事件的参数。 引用文档中的示例代码:

    const { spawn } = require('child_process');
    const ls = spawn('ls', ['-lh', '/usr']);
    
    ls.on('close', (code) => {
      console.log(`child process exited with code ${code}`);
    });
    

    【讨论】:

      猜你喜欢
      • 2010-09-24
      • 2010-12-18
      • 2015-05-06
      • 1970-01-01
      • 2015-04-03
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      相关资源
      最近更新 更多