Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get output from console window (which is a different process)

Get output from console window (which is a different process)

Scheduled Pinned Locked Moved C#
csharpasp-nettutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Programm3r
    wrote on last edited by
    #1

    Hi all, I am running the aspnet_regiis command from my application (as code example shows below). Is there any way to read the output that is displayed on the command window?

                Process start = null;
                start = Process.Start(new ProcessStartInfo()
                {
                    FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                    Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                    CreateNoWindow = true,
                    WindowStyle = ProcessWindowStyle.Hidden
                });
                start.Start();
    

    Many thanks in advance. Kind regards,

    M P 2 Replies Last reply
    0
    • P Programm3r

      Hi all, I am running the aspnet_regiis command from my application (as code example shows below). Is there any way to read the output that is displayed on the command window?

                  Process start = null;
                  start = Process.Start(new ProcessStartInfo()
                  {
                      FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                      Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                      CreateNoWindow = true,
                      WindowStyle = ProcessWindowStyle.Hidden
                  });
                  start.Start();
      

      Many thanks in advance. Kind regards,

      M Offline
      M Offline
      Martin Jarvis
      wrote on last edited by
      #2

      A quick bit of googling revealed this article: How to redirect Standard Input/Output of an application[^] It looks like you'll need to amend your code in a similare way to below:

                  Process start = null;
                  start = Process.Start(new ProcessStartInfo()
                  {
                      FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                      Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                      CreateNoWindow = true,
                      WindowStyle = ProcessWindowStyle.Hidden,
                      RedirectStandardError = true,
                      RedirectStandardOutput = true
                  });
                  start.Start();
                  StreamReader outputReader = process.StandardOutput;
                  StreamReader errorReader = process.StandardError;
      
      P 2 Replies Last reply
      0
      • M Martin Jarvis

        A quick bit of googling revealed this article: How to redirect Standard Input/Output of an application[^] It looks like you'll need to amend your code in a similare way to below:

                    Process start = null;
                    start = Process.Start(new ProcessStartInfo()
                    {
                        FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                        Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                        CreateNoWindow = true,
                        WindowStyle = ProcessWindowStyle.Hidden,
                        RedirectStandardError = true,
                        RedirectStandardOutput = true
                    });
                    start.Start();
                    StreamReader outputReader = process.StandardOutput;
                    StreamReader errorReader = process.StandardError;
        
        P Offline
        P Offline
        Programm3r
        wrote on last edited by
        #3

        Hi Martin, Many thanks for the reply, I will definitely try it out. Kind regards,

        1 Reply Last reply
        0
        • M Martin Jarvis

          A quick bit of googling revealed this article: How to redirect Standard Input/Output of an application[^] It looks like you'll need to amend your code in a similare way to below:

                      Process start = null;
                      start = Process.Start(new ProcessStartInfo()
                      {
                          FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                          Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                          CreateNoWindow = true,
                          WindowStyle = ProcessWindowStyle.Hidden,
                          RedirectStandardError = true,
                          RedirectStandardOutput = true
                      });
                      start.Start();
                      StreamReader outputReader = process.StandardOutput;
                      StreamReader errorReader = process.StandardError;
          
          P Offline
          P Offline
          Programm3r
          wrote on last edited by
          #4

          Just remeber to set the UseShellExecute property to false.

                      Process start = null;
                      start = Process.Start(new ProcessStartInfo()
                      {
                          FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                          Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                          CreateNoWindow = true,
                          UseShellExecute = false,
                          WindowStyle = ProcessWindowStyle.Hidden,
                          RedirectStandardError = true,
                          RedirectStandardOutput = true
                      });
                      start.Start();
                      StreamReader outputReader = process.StandardOutput;
                      StreamReader errorReader = process.StandardError;
          

          Thanks again. Kind regards,

          1 Reply Last reply
          0
          • P Programm3r

            Hi all, I am running the aspnet_regiis command from my application (as code example shows below). Is there any way to read the output that is displayed on the command window?

                        Process start = null;
                        start = Process.Start(new ProcessStartInfo()
                        {
                            FileName = @"C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet\_regiis.exe",
                            Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
                            CreateNoWindow = true,
                            WindowStyle = ProcessWindowStyle.Hidden
                        });
                        start.Start();
            

            Many thanks in advance. Kind regards,

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Absolutely: ProcessCommunicator[^].

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups