Link to home
Start Free TrialLog in
Avatar of fattumsdad
fattumsdad

asked on

Avoid Console Flash On Screen

Ok, one more question!  If I use this code (courtesey of eternal 21):

                  System.Diagnostics.Process process = new System.Diagnostics.Process();
                  process.StartInfo.FileName = "cmd";
                  process.StartInfo.UseShellExecute = false;
                  process.StartInfo.Arguments = "/c net send * hello world!";
                  process.Start();

Is there a way to hide the console flashing on the screen when executing command line commands?
Avatar of eternal_21
eternal_21

Sorry, fattumsdad:

  process.StartInfo.RedirectStandardOutput = true;
  process.StartInfo.RedirectStandardError = true;
I had used 'UseShellExecute = false' so that you did not see another window, but assumed that you were in a Windows Application, not a Console Application!

- eternal
Avatar of fattumsdad

ASKER

eternal,

I am in a Windows Application :) When I click on button1 to execute the command, a console window pops up for a split second and executes it, then disappears. :)
When I add:

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;

It still flashes a "command prompt" for a second :(
ASKER CERTIFIED SOLUTION
Avatar of eternal_21
eternal_21

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
eternal,

Rusty or not, you're still helping me out quite a bit!!  Works great, thanks again!!!