Solved

Avoid Console Flash On Screen

Posted on 2004-09-26
6
245 Views
Last Modified: 2012-06-27
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
Comment
Question by:fattumsdad
  • 3
  • 3
6 Comments
 
LVL 10

Expert Comment

by:eternal_21
ID: 12156805
Sorry, fattumsdad:

  process.StartInfo.RedirectStandardOutput = true;
  process.StartInfo.RedirectStandardError = true;
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 12156808
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
 
LVL 1

Author Comment

by:fattumsdad
ID: 12156819
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:fattumsdad
ID: 12156823
When I add:

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

It still flashes a "command prompt" for a second :(
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 500 total points
ID: 12156990
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
 
LVL 1

Author Comment

by:fattumsdad
ID: 12157040
eternal,

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What .NET website keeps me current? 9 55
Memory Usage 2 50
Access properties in nested observable collections 8 23
coded character set iptc field within a jpeg 1 68
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now