views:

271

answers:

2

I have a .NET winforms program that includes a feature to launch a specific web page in the system's default browser window.

It would be desirable for the page to be launched in the user's existing browser window, if one is open. The current means of launching the browser always creates a new window:

Process p = new Process();
p.StartInfo.FileName = @"C:\path\to\default\browser.exe";
p.StartInfo.Arguments = "http://pageurl";
p.Start();

This program is used exclusively on an intranet, and 99% of users are on IE6 (sad, I know.) Support for other browsers would be nice, but not required.

Any suggestions? IE6's command line parameters are sparse and do not seem to support this.

+1  A: 

Simple answer is that you cannot.

You are spawning a new process that has nothing to do with your application. You could check to see if a IExplore.EXE process is running, and do some SENDKEYS to the application window, but that is a little sketchy.

You could display the website inside a WebBrowser control, but that is totally different.

Jon
+1  A: 

What if the user is, well, using that browser page? You don't want to hijack it. Modern browsers are smart enough to create a new tab when appropriate.

Joel Coehoorn
"This program is used exclusively on an intranet, and 99% of users are on IE6"
Mike
okay. Still, you don't want to hijack an active browser window that may be in use.
Joel Coehoorn