[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

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?
0
fattumsdad
Asked:
fattumsdad
  • 3
  • 3
1 Solution
 
eternal_21Commented:
Sorry, fattumsdad:

  process.StartInfo.RedirectStandardOutput = true;
  process.StartInfo.RedirectStandardError = true;
0
 
eternal_21Commented:
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
0
 
fattumsdadAuthor Commented:
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. :)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
fattumsdadAuthor Commented:
When I add:

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

It still flashes a "command prompt" for a second :(
0
 
eternal_21Commented:
Oh man, am I getting rusty or what? :)

For a Windows Application OR a Console Application:

  process.StartInfo.CreateNoWindow = true;
  process.StartInfo.UseShellExecute = false;

You can forget about the redirect error statements, they will not be necessary if you are using "CreateNoWindow = true".  Sorry about the confusion, fattumsdad.
0
 
fattumsdadAuthor Commented:
eternal,

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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now