【发布时间】:2011-10-28 21:12:22
【问题描述】:
我想知道是否有可能以及如何通过 boost 进程在 Windows 上启动 .bat 或在 linux 脚本上启动 .sh?
【问题讨论】:
我想知道是否有可能以及如何通过 boost 进程在 Windows 上启动 .bat 或在 linux 脚本上启动 .sh?
【问题讨论】:
启动批处理文件的示例:
#include <boost/process.hpp>
#include <string>
#include <iostream>
using namespace boost::process;
int main()
{
context ctx;
ctx.environment = self::get_environment();
child c = launch("cmd", "/c batch.bat", ctx);
status s = c.wait();
if (s.exited())
std::cout << s.exit_status() << std::endl;
}
未经测试。关键是使用 /c 将批处理文件传递给 cmd
【讨论】: