2

I know that this:

Process.Start("http://www.somewebsite.com/");

launches a webpage in the users default browser. But, I am creating a useful little application, and now I need to be able to launch a URL in Chrome, Opera, Firefox, and Internet Explorer.

My default browser is Chrome, but how can I launch the URL in Opera or Firefox? This is a personal application, and is only going to be used on my computer, so there is no need to think about how to get the installation directory of the browsers.

My Firefox browswer is here: C:\Program Files\Mozilla Firefox\firefox.exe Do I need to do this by passing the URL as a command line parameter to firefox.exe when I use Process.Start()? And if that is what I need to do, can someone show me an example of how to do it?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Brandon Miller
  • 2,247
  • 8
  • 36
  • 54
  • This is exactly what you are looking for: Nice sub to use http://stackoverflow.com/questions/6613239/open-a-webpage-in-the-default-browser/#15192260 – STiTCHiCKED Mar 04 '13 at 00:56

2 Answers2

3

I did that some time ago, just use:

string browser = "chrome.exe";
//string browser = "firefox.exe";
//...

Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.FileName = browser;
myProcess.StartInfo.Arguments = "\"" + url + "\"";
myProcess.Start();
VladL
  • 12,769
  • 10
  • 63
  • 83
2
Process.Start(@"C:\Program Files\Mozilla Firefox\firefox.exe", "http://www.somewebsite.com/");

See also:
Firefox command line options
MSDN page for Process.Start

Steve Konves
  • 2,648
  • 3
  • 25
  • 44