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

  • Home
  • SEARCH
  • 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 1009779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:58:51+00:00 2026-05-16T08:58:51+00:00

So say I run my program: Process proc = new Process(); proc.StartInfo.FileName = Path.GetDirectoryName(Application.ExecutablePath)

  • 0

So say I run my program:

Process proc = new Process();
proc.StartInfo.FileName = Path.GetDirectoryName(Application.ExecutablePath)
                           + @"\Console.exe";
proc.Start();

And then wish to output my console stream to this application, how would I go about doing so?
So say I have:

Console.WriteLine("HEY!");

I want that to show up in program that I ran’s console. I know I have to redirect the output using

Console.SetOut(TextWriter);

But I have no idea how I would go about making it write to the other program.

I can see how I could do it if I were running my main program from Console.exe using RedirectStandardInput.. but that doesn’t really help 😛

  • 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-16T08:58:51+00:00Added an answer on May 16, 2026 at 8:58 am

    RedirectStandardInput makes Console.exe take its input from a stream which you can access in the main program. You can either write directly to that stream, or use SetOut to redirect console output there…

    Process proc = new Process();
    proc.StartInfo.FileName = Path.GetDirectoryName(Application.ExecutablePath)
                           + @"\Console.exe";
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.RedirectStandardInput = true;
    proc.Start();
    
    proc.StandardInput.WriteLine("Hello");
    
    Console.SetOut(proc.StandardInput);
    Console.WriteLine("World");
    

    EDIT

    It’s possible that Console.exe doesn’t cope well with having data piped into it rather than entered interactively. You could check this from the command line with something like

    echo "Hello" | Console.exe
    

    If that doesn’t do what you expect, redirecting your program’s output won’t either. To test your program without worrying about the target program, you could try

    proc.StartInfo.FileName = @"cmd";
    proc.StartInfo.Arguments = @"/C ""more""";
    

    If that displays the text that you write to it, then the problem is on the receiving end.

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

Sidebar

Related Questions

I am trying to dump a process, say calc.exe When I run my program
I'm trying to run a program, say robocopy.exe, through an aspx page using the
Say I've got something like this public void run(){ Thread behaviourThread = new Thread(abstractBehaviours[i]);
Say, I run a parallel program using MPI. Execution command mpirun -n 8 -npernode
Possible Duplicate: Elevating process privilege programatically? I'd like to build a console application in
let's say I want to run ./program with a string argument instead of typing
I have a small problem. Okay let's say from my C# console application I
Let's say I make a program. I only want this program to run on
Say I want to spawn a process and run execv to execute a command
Fist of all, when I say run a desktop app within a applet I

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.