For example, the user has multiple browsers: Chrome, Firefox, and Safari, and the user's default browser is Chrome. How can I make it so that when the code opens the user a link, it will use Safari instead of his default browser, which is Chrome? Is that even possible? Thanks :)
2 Answers
Try this:
System.Diagnostics.Process.Start("Chrome.exe", "http://www.stackoverflow.com");//or firefox.exe You might have exceptions if the browser is not configured correctly. So it is better to catch the exception like this:
try { System.Diagnostics.Process.Start("Chrome.exe", "http://www.stackoverflow.com");//or firefox.exe } catch(System.ComponentModel.Win32Exception noBrowser) { if (noBrowser.ErrorCode == -2147467259) MessageBox.Show(noBrowser.Message); } catch (System.Exception other) { MessageBox.Show(other.Message); }
Process.Start()and you need to specify the browser name in it which you want to open, For Safari use its exe name likeProcess.Start("safari.exe","http://www.stackoverflow.com")