如何启动脚本(.sh或.bat)VAI Boost进程? [英] How to launch a script (.sh or .bat) vai boost process?

查看:117
本文介绍了如何启动脚本(.sh或.bat)VAI Boost进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能,以及如何通过提升过程在Windows上启动.bat或在Linux脚本上启动.sh?

I wonder is it possible and how to launch a .bat on Windows or .sh on linux script via boost process?

推荐答案

启动批处理文件的示例:

Example to start a batch file:

#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

Untested. The key is passing the batch file to cmd with /c

这篇关于如何启动脚本(.sh或.bat)VAI Boost进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆