Solved

Avoid Console Flash On Screen

Posted on 2004-09-26
6
244 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
Comment Utility
Sorry, fattumsdad:

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

Expert Comment

by:eternal_21
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Author Comment

by:fattumsdad
Comment Utility
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
Comment Utility
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
Comment Utility
eternal,

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

18 Experts available now in Live!

Get 1:1 Help Now