Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process won't start minimized in c#

pro.StartInfo.FileName =  @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";

pro.StartInfo.Arguments = a;
pro.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;

pro.Start();

I have this code above which starts Firefox minimized. but Firefox does not actually start minimized but as a normal window. What is the problem with my code? Do I have to sleep the thread for 100 ms ?

like image 360
Dionysis Nt. Avatar asked Apr 17 '15 09:04

Dionysis Nt.


1 Answers

Try out this one :)

pro.StartInfo.FileName =  @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";

pro.StartInfo.Arguments = a;
pro.UseShellExecute = true;
pro.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;

pro.Start();

As I think this will only work if firefox is NOT running. Else it will still open firefox, but not minimized. If you want to minimize your own starting firefox if the process is already up, you will need to handle ShowWindow as described here.

like image 176
C4d Avatar answered Sep 17 '22 15:09

C4d