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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:01:57+00:00 2026-05-25T02:01:57+00:00

In 2 parts of the C++/CLI code I’m working on, the program needs to

  • 0

In 2 parts of the C++/CLI code I’m working on, the program needs to run a different executable and have its STDOUT output redirected to a file. Its being attempted in 2 different ways, and only one of the 2 currently works. The program is being run on Windows XP.

The first section assembles a long char* that ends up looking something like this:

char* exepath = "start/B /D\\root\\bin \\root\\bin\\process.exe 1>\\root\\logs\\process_STDOUT.txt"

Then the code simply calls

Status = system(exepath);

This works fine: It both runs process.exe and creates the process_STDOUT.txt file as expected.

The second section tries to do the same using a ProcessStartInfo object instead. It successfully starts process.exe, but has not been creating the redirected output .txt file. Here is a simplified version of that code:

 Process p = gcnew Process();
 ProcessStartInfo^ s = gcnew ProcessStartInfo();
 s->FileName         = "\\root\\bin\\process.exe";
 s->WindowStyle      = ProcessWindowStyle::Hidden;
 s->CreateNoWindow   = true;
 s->UseShellExecute  = false;
 s->Arguments        = "1>\\root\\logs\\process_STDOUT.txt";
 p->StartInfo        = s;
 p->Start();

Am I doing something wrong with this code? And if not, is going back to just calling system(exepath) my only option or are there any others?

  • 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-05-25T02:01:57+00:00Added an answer on May 25, 2026 at 2:01 am

    The system function invokes the system’s command-line interpretter, which on Windows is usually cmd.exe. That’s the program that parses the I/O-redirection syntax. The program you’re starting has no idea what > means; it interprets that as the first character of an actual command-line argument. (Think about it — have you ever written command-line-redirection code in your command-line programs? No, of course not. Neither did the author of process.exe.)

    So that’s why your ProcessStartInfo method doesn’t redirect I/O. For that, see the question here about redirecting stdin and stdout in .Net.

    Since you’re redirecting output to a file anyway, your current system code should be fine. The more programmatic ways of redirecting are necessary when you want to collect the output within your program instead of a file.

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

Sidebar

Related Questions

I'm using VS2008 to build a plain old C++ program (not C++/CLI). I have
So I have a native 3rd party C++ code base I am working with
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
I have some long-running CLI PHP scripts that run regularly via cron. I'd like
Without using p/invoke, from a C++/CLI I have succeeded in integrating various methods of
I have a C++ assembly with both managed and umanaged code compiled to a
I have a pipeline that I currently run on a large university computer cluster.
I have a C++/CLI .net application and I encountered a peculiar exception the other
I have a project written in C++/CLI. Some of the types there are in
I have a custom plugin that I run on all our projects as part

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.