Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:39:18+00:00 2026-06-17T04:39:18+00:00

I am invoking a batch script through cmd.exe /C with Boost.process boost::process::context context; context.stdout_behavior

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:39:19+00:00Added an answer on June 17, 2026 at 4:39 am

    What I discovered is boost::process::context is not cross platform. I’ve to use boost::process::win32_context on Windows. and may be there was a problem with silence_stream or that may be a problem in my side.

    //I've a list of argv in arguments
    
    #ifdef WIN32
      arguments.pop_front();
      arguments.push_front(_script);
      arguments.push_front("/C");
      arguments.push_front("script.bat");
    
      boost::process::win32_context win32_context;
      win32_context.stdout_behavior = boost::process::capture_stream();
      win32_context.environment = boost::process::self::get_environment(); 
    
      boost::process::child external_process = boost::process::win32_launch(std::string("C:/Windows/System32/cmd.exe"), arguments, win32_context);
    #else
      boost::process::context context;
      context.stdout_behavior = boost::process::silence_stream();
    
      boost::process::child external_process = boost::process::launch(_script, arguments, context);
    #endif
    
      boost::process::status status_code = external_process.wait();
    

    It was not getting PATH so applications were failing to find dll. win32_context.environment = boost::process::self::get_environment() fixed that issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use CreateProcess (or ShellExecute , or any other means of invoking cmd.exe
When i am using batch file for invoking msbuild.exe ,logging functionality works fine. But
Possible Duplicate: Invoking methods with optional parameters through reflection Name of the constructor arguments
When invoking the 'java' process, I'm almost certain there is a way to have
I am invoking a shell script using Kernel.system from my Rails controller. The shell
Invoking a groovy script using CLASSPATH prefix as follows works fine: CLASSPATH=/path/to/classes groovy -e
I'm invoking a NSOpenPanel from a thread created by boost C++. the panel behaves
I found a C# example here of invoking a PowerShell script asynchronously from a
I want to create a batch file, batch.bat , that accepts 2 mandatory arguments:
I am executing MSBuild from a batch file. The MSBuild script is in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.