Search code examples
c#windowsprocessprocessstartinfo

Prevent child process from showing a shell window in c#


I'm using ffmpeg to compile videos, and I'd like to prevent it from displaying a console when performing actions.

Here's how I start ffmpeg:

ProcessStartInfo si = new ProcessStartInfo();
si.Arguments = string.Format("-y -loop 1 -t " + DucationToString(frameDuration) + " -r 25 -f image2 -i \"{0}\" \"{1}\"",
                             item.Value, otpt);
si.FileName = "ffmpeg";
si.UseShellExecute = false;

Process.Start(si).WaitForExit();

No matter the settings I try in ProcessStartInfo, the console always shows up.

How do I prevent the console from being shown when creating child process?


Solution

  • You should try to use

    ProcessStartInfo si = new ProcessStartInfo();
    si.WindowStyle = ProcessWindowStyle.Hidden;
    si.CreateNoWindow = true;
    si.UseShellExecute = false;
    

    MSDN refs