By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Launching a browser

P: n/a
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?
--
Alan M Dunsmuir
Nov 21 '05 #1
Share this Question
Share on Google+
24 Replies


P: n/a
Hi,

Process.Start(Http://msdn.microsoft.com)

Ken
-----------------------
"Alan M Dunsmuir" <al**@moonrake.demon.co.uk> wrote in message
news:g4**************@moonrake.demon.co.uk...
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?
--
Alan M Dunsmuir
Nov 21 '05 #2

P: n/a
"Alan M Dunsmuir" <al**@moonrake.demon.co.uk> schrieb:
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?


Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

P: n/a
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]"
<hi***************@gmx.at> wrote:

< snip >

Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>

Nov 21 '05 #4

P: n/a
rs
try this:

System.Diagnostics.Process.Start("IExplore.exe", www.whatever.com)

that should open a new window
"- HAL9000" <gu***@mail.org> wrote in message
news:mp********************************@4ax.com...
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]"
<hi***************@gmx.at> wrote:

< snip >

Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>


Nov 21 '05 #5

P: n/a
rs
thats not the default browser though.
"rs" <aa@d.com> wrote in message news:ct********************@rogers.com...
try this:

System.Diagnostics.Process.Start("IExplore.exe", www.whatever.com)

that should open a new window
"- HAL9000" <gu***@mail.org> wrote in message
news:mp********************************@4ax.com...
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]"
<hi***************@gmx.at> wrote:

< snip >

Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>



Nov 21 '05 #6

P: n/a
Sorry for spelling error, this is correctly source:
System.Diagnostics.Process.Start("www.yahoo.com")

"msDev" <ne*******@mail.bg> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
If You want open link in default browser? See this example:

System.Siagnostics.Process.Start(www.yahoo.com)

"- HAL9000" <gu***@mail.org> wrote in message
news:mp********************************@4ax.com...
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]"
<hi***************@gmx.at> wrote:

< snip >

Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>



Nov 21 '05 #7

P: n/a
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.
On Thu, 30 Dec 2004 10:27:28 +0200, "msDev" <ne*******@mail.bg> wrote:
Sorry for spelling error, this is correctly source:
System.Diagnostics.Process.Start("www.yahoo.com ")

< snip >
>
> 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?

< snip >

Nov 21 '05 #8

P: n/a
"- HAL9000" <gu***@mail.org> schrieb:
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)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #9

P: n/a
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]"
<hi***************@gmx.at> wrote:

< snip >

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 >

Nov 21 '05 #10

P: n/a
"- HAL9000" <gu***@mail.org> schrieb:
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>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #11

P: n/a
Cool, thanks !
Nov 21 '05 #12

P: n/a

"- HAL9000" <gu***@mail.org> wrote
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
Nov 21 '05 #13

P: n/a
Larry,

"Larry Serflaten" <se*******@usinternet.com> schrieb:
<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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #14

P: n/a

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote
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
Nov 21 '05 #15

P: n/a
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

"Larry Serflaten" <se*******@usinternet.com>

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote
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

Nov 21 '05 #16

P: n/a
"Cor Ligthert" <no************@planet.nl> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #17

P: n/a
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.SpecialFolde r.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


Nov 21 '05 #18

P: n/a

"Cor Ligthert" <no************@planet.nl> wrote
I thought that this will solve the problem of the OP (when he uses IE)


And what to do when he doesn't use IE?

<g>
LFS
Nov 21 '05 #19

P: n/a
Larry,
I thought that this will solve the problem of the OP (when he uses IE)
And what to do when he doesn't use IE?


Exactly therefore it was not a "best" answer, however better than nothing.

(I stopped with the chalenge by the way to much typing, I go first using the
DLL)

:-)

Cor
Nov 21 '05 #20

P: n/a
Larry

And because suddenly everybody (excluding you) started to talk about IE,
while it was in the beginning the Defaul Browser where Ken's first answer
did directly fit in my opinion (except that IE in that case is stealing the
acrtive browser).

Cor
Nov 21 '05 #21

P: n/a

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote
The "best" solution for launching /MSIE/ with a certain webpage in a new
window is IMO:


If MSIE is the desired browser, then it gets even simpler:

Shell("explorer http://www.google.com")

As long as we're on the topic, there are quite a few views that can be
gotten from that same syntax (which was brought forward from VB6).
So, just for reference, here are all that I've found so far:

Private Const sysIExplorer$ = ", ::{871C5380-42A0-1069-A2EA-08002B30309D}"
Private Const sysNetworkPlaces$ = ", ::{208D2C60-3AEA-1069-A2D7-08002B30309D}"
Private Const sysRecycleBin$ = ", ::{645FF040-5081-101B-9F08-00AA002F954E}"
Private Const sysTasks$ = ", ::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"

Private Const sysComputer$ = ", ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
Private Const sysDesktop$ = sysComputer & " /select,"

Private Const sysDocuments$ = ", ::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
Private Const sysFax$ = sysDocuments & "\Fax"
Private Const sysPictures$ = sysDocuments & "\My Pictures"

Private Const sysControlPanel$ = sysComputer & "\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"
Private Const sysAdminTools$ = sysControlPanel & "\::{D20EA4E1-3957-11d2-A40B-0C5020524153}"
Private Const sysConnections$ = sysControlPanel & "\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
Private Const sysFonts$ = sysControlPanel & "\::{D20EA4E1-3957-11d2-A40B-0C5020524152}"
Private Const sysPrinters$ = sysControlPanel & "\::{2227A280-3AEA-1069-A2DE-08002B30309D}"
For an example, to call up the Control Panel:

Shell("explorer " & sysControlPanel, AppWinStyle.NormalFocus)

Now, the question is, do they also work on your foreign language OS?

LFS

Nov 21 '05 #22

P: n/a
Use ProcessStartInfo - but set the CreateNoWindow property to False.

"- HAL9000" wrote:
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]"
<hi***************@gmx.at> wrote:

< snip >

Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>


Nov 21 '05 #23

P: n/a
"chili" <ch***@discussions.microsoft.com> schrieb:
Use ProcessStartInfo - but set the CreateNoWindow property to False.


I am just curious why you suggest to do that.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #24

P: n/a
>> Use ProcessStartInfo - but set the CreateNoWindow property to False.

I am just curious why you suggest to do that.


me too

:-)

Cor
Nov 21 '05 #25

This discussion thread is closed

Replies have been disabled for this discussion.