Launching a browser

  • Thread starter Thread starter Alan M Dunsmuir
  • Start date Start date
A

Alan M Dunsmuir

What is the command (in Windows Forms VB.NET) which will cause the
subject computer's default browser to launch, and display a specified
Web page?
 
I read the link.

Shell("http://www.yahoo.com/")

Doesn't work for me. Exception from
'System.IO.FileNotFoundException' : File not found.

What I don't like about

Process.Start(psi)

is that a new IE window is not launched, any existing IE window is
high jacked. Is there a way to launch a new window of the default
browser and point to a URL?

Thanks...


On Sat, 25 Dec 2004 13:03:18 +0100, "Herfried K. Wagner [MVP]"
 
What is wrong with Ken's sample except that he forgot to type the quotes
what everybody can see in my opinion?

Cor
 
Ok, yea, I've used that.

The problem, as I mentioned, is that 'Start("www.yahoo.com")' does not
start a new IE window. Any existing IE window is hijacked.

Try Process.Start for yourself with multiple IE windows open. A new
IE window doesn't launch....

Seems like their should be an argument option in the Start to open a
new window - just don't know what it is.


Sorry for spelling error, this is correctly source:
System.Diagnostics.Process.Start("www.yahoo.com")
< snip >
 
- HAL9000 said:
Try Process.Start for yourself with multiple IE windows open. A new
IE window doesn't launch....

There is an option in Internet Explorer's "Tools" -> "Internet
Options..." -> "Advanced" (translated from the German version, please excuse
deviations) that gives you the control whether a new window should be opened
or an already opened window should be reused when a Web document is opened.

Alternatively you can try this code (untested and written from scratch). It
will start MSIE, even if another browser has been selected as the system's
default browser:

\\\
Imports System.Diagnostics
..
..
..
Dim psi As New ProcessStartInfo()
With psi
.FileName = "iexplore"
.Arguments = "http://www.example.org/"
End With
Process.Start(psi)
///
 
Ok, I see the IE Advanced option for "Reuse Windows For Launching
Shortcuts". Looks like it defaults to "checked" on winxp
installation.

So does that mean that their is a registry entry for that IE option?
If so, can one read/modify it?

Thanks...


On Thu, 30 Dec 2004 22:36:52 +0100, "Herfried K. Wagner [MVP]"

There is an option in Internet Explorer's "Tools" -> "Internet
Options..." -> "Advanced" (translated from the German version, please excuse
deviations) that gives you the control whether a new window should be opened
or an already opened window should be reused when a Web document is opened.
< snip >
 
- HAL9000 said:
Ok, I see the IE Advanced option for "Reuse Windows For Launching
Shortcuts". Looks like it defaults to "checked" on winxp
installation.

So does that mean that their is a registry entry for that IE option?
If so, can one read/modify it?

I doubt that the user will be happy if a program changes this setting.

Description of the Reuse Windows for Launching Shortcuts Setting in Internet
Explorer 5.01
<URL:http://support.microsoft.com/?scid=kb;EN-US;241911>
 
- HAL9000 said:
Ok, I see the IE Advanced option for "Reuse Windows For Launching
Shortcuts". Looks like it defaults to "checked" on winxp
installation.

So does that mean that their is a registry entry for that IE option?
If so, can one read/modify it?

Rather than change a user's system settings, I would suggest you
throw together a fix that will suit your needs, and leave the user
keep their own settings.

One way to work around the problem is to start a new process that
loads a local HTM file, where the HTM file is a redirect to the page
you want to go to. You could create the HTM file from your program
and launch it using the Process.Start method. For an example, Paste
the following into Notepad and save it somewhere as Redirect.htm.

<HTML><HEAD>
<META http-equiv="refresh" content="0;URL=http://www.google.com"></META>
</HEAD></HTML>

Assuming you save that to D:\temp\redirect.htm, you can call it like:

Process.Start("d:\temp\redirect.htm")

(Be advised, not all browsers support the refresh directive.)

I personally don't like software that thinks it owns the system just
because I let it execute. Software that changes settings I regularly use
isn't going to remain on my system for long (if I can help it...) I
suspect your users would prefer the indirect route, rather than you
accessing various parts of their Registry.

HTH
LFS
 
Larry,

Larry Serflaten said:
<HTML><HEAD>
<META http-equiv="refresh" content="0;URL=http://www.google.com"></META>
</HEAD></HTML>

Assuming you save that to D:\temp\redirect.htm, you can call it like:

Process.Start("d:\temp\redirect.htm")

(Be advised, not all browsers support the refresh directive.)

In this case providing a hyperlink to the webpage in the HTML document's
body would make it easier for the user to browse to the page {him, her}self.
 
Herfried K. Wagner said:
In this case providing a hyperlink to the webpage in the HTML document's
body would make it easier for the user to browse to the page {him, her}self.

Yeah that is possible, but that would not resolve the original question; how to
launch a browser to show a specific page....

;-)
LFS
 
Larry,

I did not follow the question anymore when there came no answer on my
question, however now I see you are active as well in it I was curious to
your answers in this thread.

I thought that this will solve the problem of the OP (when he uses IE)

\\\
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.FileName = _
"C:\Program Files\Internet Explorer\iexplore.exe"
pi.Arguments = "msdn.microsoft.com"
p.StartInfo = pi
p.Start()
////

Cor
 
Cor Ligthert said:
I thought that this will solve the problem of the OP (when he uses IE)

\\\
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.FileName = _
"C:\Program Files\Internet Explorer\iexplore.exe"
pi.Arguments = "msdn.microsoft.com"
p.StartInfo = pi
p.Start()

This would fail on my system because on German Windows versions "Program
Files" is called "Programme", and Windows is not necessarily installed on
the "C" drive. Using "iexplore" only as a filename would have a bigger
chance to work on different systems.

The "best" solution for launching /MSIE/ with a certain webpage in a new
window is IMO:

\\\
Imports System.Diagnostics
..
..
..
Dim psi As New ProcessStartInfo()
With psi
.FileName = "iexplore"
.Arguments = "-new http://dotnet.mvps.org/"
End With
Process.Start(psi)
///

Command-line switches for MSIE are documented here:

INFO: Command-Line Switches for Internet Explorer 4.0
<URL:http://support.microsoft.com/?id=178058>

To make a conclusion: When showing a webpage from within a program, I
/would not/ call a specific browser. Instead, I'd launch the document in
the default browser. If the user has chosen to reuse browser instances,
then they should be reused. If the user wants the page to be shown in a
separate browser window, he/she should uncheck the option to reuse existing
browser windows.
 
Herfried,
This would fail on my system because on German Windows versions "Program
Files" is called "Programme", and Windows is not necessarily installed on
the "C" drive. Using "iexplore" only as a filename would have a bigger
chance to work on different systems.
Interesting, in the Dutch it is just on the same name as the English one.

Otherwise I had used of course
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
However it was not to show the "best" solution, because I even did not know
how it would act on a W9x computer, just show how it could be done.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top