Hide process window...

Posted on 2006-04-18
Last Modified: 2012-05-05
I am trying to create a process to execute command line command, and redirect the result to the process stream reader...
The problem is I cannot hide the command (dos) window... even I setup WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
Here is my code ...
Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "p4";
myProcess.StartInfo.Arguments = @"-p testServer:1234 -c test_client files C:\test.xml";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
string output = myProcess.StandardOutput.ReadToEnd();
Could you help me to hide the command window?
Thank you!
Question by:billcch
    LVL 12

    Accepted Solution


         myProcess.StartInfo.CreateNoWindow = true;

     before myProcess.Start()
    LVL 12

    Expert Comment


    Also, note that is a good practice to read the output buffer before calling WaitForExit method, as if the process writes out to many data, it can cause a deadlock.
    See  or,  
     ( for .Net framework 1.1)
    LVL 11

    Assisted Solution

    Process.WaitForExit does not need to be called at all, in this example, as the Process.StandardOutput.ReadToEnd method will not return until the standard output stream has closed (i.e. the process has exited).

    Author Comment

    Thank you so much!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    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…
    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…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now