I am invoking a batch script through cmd.exe /C with Boost.process
boost::process::context context;
context.stdout_behavior = boost::process::capture_stream();
#ifdef WIN32
arguments.push_front("/c");
arguments.push_front(_script);
boost::process::child external_process = boost::process::launch("cmd.exe", arguments, context);
#else
boost::process::child external_process = boost::process::launch(_script, arguments, context);
#endif
boost::process::status status_code = external_process.wait();
If I directly invoke the batch file even with cmd.exe /C it calls the external executable.
But when the batch script is called through my program it doesn’t call the external program at all.
The external executable generates some file. also prints some texts to stdout. neither I see those texts not I see any files to be generated.
I’ve even tried to replace the target executable with notepad.exe then a message box appears Application failed to initialize properly (0xc0150004) click on OK to terminate application
What I discovered is
boost::process::contextis not cross platform. I’ve to useboost::process::win32_contexton Windows. and may be there was a problem withsilence_streamor that may be a problem in my side.It was not getting
PATHso applications were failing to finddll.win32_context.environment = boost::process::self::get_environment()fixed that issue.