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

    Question

  • 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.
    Wednesday, March 14, 2007 3:49 PM

Answers

  • 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
    Tuesday, March 20, 2007 8:27 PM

All replies

  • I believe you want to set UseShellExecute to false.

    Process p = new Process();

    p.StartInfo.UseShellExecute = false;

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

    p.Start();
    Wednesday, March 14, 2007 4:52 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 4:45 PM
  • 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
    Tuesday, March 20, 2007 8:27 PM
  • 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
    Thursday, October 08, 2009 10:54 AM