Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process.Start("IExplore.exe"); <-- Is this reliable?

Tags:

c#

.net

winapi

Process.Start("IExplore.exe");

Does this always work, on every machine ? If not, how to do it properly ?

... EDIT: .................................

The problem with Process.Start("http://www.example.com/"); is that we have to target a local html file, with some querystring specifying which page to load in the html frameset. So our URL looks like the following:

G:\PathToHelpFolder\index.html#search?page=1.html

If you pass this path to Process.Start, an error is generated: "cannot find the file". This is caused by the querystring at the end. (#search?page=1.html)

So, we have to start explorer (or default browser would be better) with the filepath as a command line argument. We found the method above at the MSDN documentation. (Process.Start("IExplore.exe");) Our only question is if this method is reliable enough to deploy to a commercial app. Mono isn't a problem, only windows systems are targeted.

... EDIT : Our solution ......

Our solution was to get the default browser from the registry, and start that with the filename as argument. (as stated in: Launching default browser with html from file, then jump to specific anchor)

like image 614
Run CMD Avatar asked May 13 '10 13:05

Run CMD


2 Answers

If your goal is to open a browser to go to a specific page, it's better to use just the page URL:

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

That way, the user's default browser will be used. (I, for one, would be annoyed to be forced into using IE.)

like image 137
Thomas Avatar answered Oct 21 '22 22:10

Thomas


I once needed the default browser's name (without opening) for a stupid application I built, I found a great tutorial over here: http://ryanfarley.com/blog/archive/2004/05/16/649.aspx

like image 22
Blank6 Avatar answered Oct 21 '22 22:10

Blank6