9
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 ?

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
Dionysis Nt.
  • 955
  • 1
  • 6
  • 16

2 Answers2

5

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.

C4d
  • 3,183
  • 4
  • 29
  • 50
-1

to start a process without opening a terminal windows one can do like this:

 ProcessStartInfo pro = new ProcessStartInfo();

 pro.FileName = 'pathToFile'
 pro.RedirectStandardInput = true;
 pro.RedirectStandardOutput = false;
 pro.Arguments = 'some arguments'
 pro.UseShellExecute = false;
 pro.CreateNoWindow = true; // <- imp. line
Miguel Tomás
  • 1,714
  • 1
  • 13
  • 23