views:

37

answers:

1

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.

+1  A: 

Set the ProcessStartInfo.CreateNoWindow property to true

fletcher
Ah, I had used that before but didn't think it made a difference when I used `ProcessWindowStyle.Hidden`. And I needed to set it to true, not false.Thanks very much! :)
Kratz
Yeah, it's getting late here. I messed up, double negatives...
fletcher