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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:22:05+00:00 2026-05-26T05:22:05+00:00

I was in the market looking for a tabbed command prompt application, as I

  • 0

I was in the market looking for a “tabbed” command prompt application, as I was sick of having multiple command prompt windows cluttering one of my desktop screens, when I thought of a possibility of creating my own. While I understand that it won’t be as great as a standalone product, but I think it will be a good exercise to create my own just to get more familiar with the “System.Diagnostic” classes (Process, ProcessStartInfo, etc.) that I’ve never really played around with before.

I’ve pretty much just created a barebones winforms app that has 2 tabs (that contain richtextfields), a textfield (to enter the command) and a button (to actually run the command).

I found various posts that show how to run a command, but I’m having problems actually executing a command and returning the results to the richtextbox. Here is a method I created based on what info I know for now:
(Updated base on previous answers)

public void GetConsoleOuput(string command)
{
  string outputString;

  ProcessStartInfo startupInfo = new ProcessStartInfo()
  startInfo.FileName = "cmd.exe";
  startInfo.RedirectStandardOuput = true;
  startInfo.WindowStyle = ProcessWindowStyle.Hidden:
  startInfo.UseShellExecute = false;

  startInfo.Arguments("/C " + command);

  Process process = new Process()
  process.StartInfo = startInfo;
  process.OutputDataReceived += new DataReceivedEventHandler(AppendRichBoxText);

  process.Start()
  process.BeginOutputReadLine();

  process.WaitForExit();
  process.Close();
}

public void AppendRichBoxTet(object sender, DataReceivedEventArgs args)
{
  string outputString = args.Data;

  // need to have the richTextBox updated using it's own thread
  richTextBox.BeginInvoke( /* not sure what to put inside here */);
}

The use of this method would be to keep appending the output text to the richtextbox.

At this point, I’m stuck on how to execute the BeginInvoke method so that this richTextBox will have it’s text updated on it’s own thread.

  • 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-26T05:22:06+00:00Added an answer on May 26, 2026 at 5:22 am

    Yes, you can. Instead of using ReadToEnd (which will block until the process finishes) you can use the event-driven output redirection API:

    • Set RedirectStandardOutput as you are doing already
    • Start the process
    • Call BeginOutputReadLine
    • Subscribe to the OutputDataReceived event and use Control.BeginInvoke to marshal back to the UI thread to append to the RichTextBox.

    There’s an example in the BeginOutputReadLine documentation.

    EDIT: For the Control.BeginInvoke, this would probably be the simplest solution:

    public void AppendRichBoxTet(object sender, DataReceivedEventArgs args)
    {
      string outputString = args.Data;
      MethodInvoker append = () => richTextBox.AppendText(outputString);
      richTextBox.BeginInvoke(append);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking for a way to calculate dynamic market values in a soccer
I've an application in the market and many users have reported that the app
I'm looking for an Application Programming Interface which will allow me to access quotes
I'm planning a client-server product for a tiny, low-volume, high-cost vertical market. One of
I recently finished my first Android application and will submit it to market in
Is it a good solution to use SocketAsyncEventArgs for a Client application receiving market
We are currently working on a new version of our main application. one thing
I am looking into multiple web testing tools. I am trying watir now. My
I recently launched my application to the Market and I've been in contact with
We will be developing a very large vertical market web application, and are leaning

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.