Hide the DOS window when running an external .exe process

Answered Hide the DOS window when running an external .exe process

  • Wednesday, March 14, 2007 3:49 PM
     
     
    Hi, somewhere in my Windows Form program, I need to run an external .exe process using Process.start(myprogram.exe). But every time when I do this, the myprogram.exe DOS window shows up. Is there a way to hide it while the process is running? Thanks.

All Replies

  • Wednesday, March 14, 2007 4:52 PM
     
     
    I believe you want to set UseShellExecute to false.

    Process p = new Process();

    p.StartInfo.UseShellExecute = false;

    p.StartInfo.FileName = "my.exe";

    p.Start();
  • Tuesday, March 20, 2007 4:45 PM
     
     
    Doesn't work for me when the console app must be kept running for a while. I can redirect the input and output, but the console window pops up never the less and stays empty if I redirect the output. The empty window stays till the console app finishes, or is closed from my window application.
    Is it even possible to hide the console window completely during runtime of the called executable ?
  • Tuesday, March 20, 2007 8:27 PM
     
     Answered
    Process process = new Process();
    process.StartInfo.FileName = "ping.exe";
    process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    process.Start();

    just use the WindowStyle property and set it to Hidden
  • Thursday, October 08, 2009 10:54 AM
     
     Proposed Answer
    For me I had to use the CreateNoWindow property like below to run gacutil to make it work... WindowStyle didn't help
    (observe that I needed the RedirectStandardOutput set to true, don't know if it had any impact)

    Process p = new Process {
      StartInfo = new ProcessStartInfo("gacutil.exe /i myassembly.dll") {
        UseShellExecute = false,
        CreateNoWindow = true,
        RedirectStandardOutput = true,
      }
    };
    p.Start()
    Dan
    • Proposed As Answer by Dan Händevik Thursday, October 08, 2009 10:54 AM
    •