How can I start a process in the background?

Robert Malansangan picture Robert Malansangan · Jul 25, 2015 · Viewed 29.9k times · Source

I can't seem to find an answer on Google or here on StackOverflow.

How can I start a process in background (behind the active window)? Like, when the process starts, it will not interrupt the current application the user is using.

The process won't pop out in front of the current application, it will just start.

This is what I'm using:

Process.Start(Chrome.exe);

Chrome pops up in front of my application when it's started. How can I make it start in background?

I've also tried:

psi = new ProcessStartInfo ("Chrome.exe");
psi.UseShellExecute = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(psi);

But there's no difference at all from the previous one.

Thanks.

Answer

Tayla Wilson picture Tayla Wilson · Jul 25, 2015

Try this:

 Process p = new Process();
        p.StartInfo = new ProcessStartInfo("Chrome.exe");
        p.StartInfo.WorkingDirectory = @"C:\Program Files\Chrome";
        p.StartInfo.CreateNoWindow = true;
        p.Start();

Also, if that doesn't work, try adding

p.StartInfo.UseShellExecute = false;