Get output from console window (which is a different process)
-
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,
-
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,
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;
-
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;
Hi Martin, Many thanks for the reply, I will definitely try it out. Kind regards,
-
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;
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,
-
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,
Absolutely: ProcessCommunicator[^].