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 7900625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:00:56+00:00 2026-06-03T09:00:56+00:00

I have this static std::string exec(char* cmd) { FILE* pipe = _popen(cmd, r); if

  • 0

I have this

static std::string exec(char* cmd) {
            FILE* pipe = _popen(cmd, "r");
            if (!pipe) return "ERROR -22";
            char buffer[128];
            std::string result = "";
            while(!feof(pipe)) {
                if(fgets(buffer, 128, pipe) != NULL)
                        result += buffer;
            }
            _pclose(pipe);
            return result;

}

But the problem i have is that i want to hide the program that lunches how can I do that? thx

  • 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-03T09:00:57+00:00Added an answer on June 3, 2026 at 9:00 am

    As Hans Passant mentioned in the comments, you have to use CreateProcess to spawn the child process instead of _popen, since _popen does not give you any control over the window creation process.

    To hide the console window, use the CREATE_NO_WINDOW process creation flag for the dwCreationFlags parameter.

    In order to capture the output of the process, you need to create a pipe for its standard output stream with CreatePipe. Assign that pipe handle to the hStdOutput member of the STARTUPINFO structure you pass in, and make sure to set the STARTF_USESTDHANDLES flag in the startup info’s dwFlags so it knows that that member is valid. Then, to read data, you just use ReadFile on the pipe handle.

    Hans also provided a link to a good example of creating pipes with a child process here, although that example is doing more than you need to do—it’s creating pipes for all three streams (stdin, stdout, and stderr), whereas you only need to capture stdout.

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

Sidebar

Related Questions

I have some code that looks like: static const std::string and( AND ); This
I have some methods like this in my class: static std::string numberToString(int n); static
I have this function: public static int checkRank(String lineToCompare){ int rank = 0; try{
I have this regex: private static final String SPACE_PATH_REGEX =[a-z|A-Z|0-9|\\/|\\-|\\_|\\+]+; I check if my
I have a static std::map<std::string, CreateGUIFunc> in a class that basically holds strings identifying
I have a class with a static std::map member variable that maps char s
Say I have defined a variable like this (C++): static const char str[] =
Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
I have this static function which basicly makes a connection to a webpage, send
I have this static callback function in MyClass, and I try to call another

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.