2011-10-28 55 views

回答

1

實施例來啓動一個批處理文件:

#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; 
} 

未測試。關鍵是將批處理文件傳遞到cmd中,並使用/ c