Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 FilesMozilla Firefoxfirefox.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
554 views
Welcome To Ask or Share your Answers For Others

1 Answer

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...