Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console window still popping up even after ProcessWindowStyle.Hidden;

I have to run a console application from my Windows Application. The console application I want to run is an Embedded Resource in my application, and I am calling it like this:

// Run the updater and grab its output
Process Updater = new Process();
Updater.StartInfo.FileName = "C:\\tmp\\tmp.exe";
Updater.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Updater.StartInfo.UseShellExecute = false;
Updater.StartInfo.RedirectStandardOutput = true;
Updater.Start();
string UpdaterOutput = Updater.StandardOutput.ReadToEnd();
Updater.WaitForExit();

It extracts fine, and it runs fine, and it also grabs its output completely fine... but I can still see the console Window popping open quickly as it's run. I know the console pop up is from this application because the console title is C:\tmp\tmp.exe. Is there any completely fail proof way to hide the console application? I thought using ProcessWindowStyle.Hidden would do it but apparently not.

Thanks.

like image 444
Kratz Avatar asked Aug 16 '10 22:08

Kratz


1 Answers

Set the ProcessStartInfo.CreateNoWindow property to true

like image 85
fletcher Avatar answered Oct 19 '22 09:10

fletcher