|
|
#1 |
|
Moderator.NET
Join Date: Nov 01
Location: NJ - USA (Near NYC)
Posts: 22,435
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Shell to a new browser to open a URL
In .NET, you can navigate to a website, simply by typing
process.start("www.vbforums.com") but the problem with this, is that it will open vbforums website in a browser window you already have open... There is no way to specify to open a new instance of IE (or another webbrowser) You could simply launch IE with the website as a commandline arg, but what if the user doesn't want to use IE? It is better to not depend on a specific browser... My code simply creates a temporary HTM file, then finds what exe is associated with HTM files on the system, and launches that browser and navigates to the page. http://www.vbforums.com/attachment.p...chmentid=33874
__________________
Using VB.NET 2010/.NET 2.0 through 4.0 * Please mark you thread resolved using the Thread Tools above ![]() PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!! * If you found a post useful then please Rate it! Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup ZerosAndTheOne.com -=Matt=- |
|
|
|
|
|
#2 |
|
New Member
Join Date: Jul 05
Posts: 1
![]() |
Re: Shell to a new browser to open a URL
why don't use this command
shell "explorer.exe http://vbforums.com" |
|
|
|
|
|
#3 | |
|
Moderator.NET
Join Date: Nov 01
Location: NJ - USA (Near NYC)
Posts: 22,435
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Shell to a new browser to open a URL
Quote:
This code will shell your DEFAULT browser, which means if you use firefox, netscape, opera, etc... this will shell THAT browser to the desired page. make sense?
__________________
Using VB.NET 2010/.NET 2.0 through 4.0 * Please mark you thread resolved using the Thread Tools above ![]() PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!! * If you found a post useful then please Rate it! Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup ZerosAndTheOne.com -=Matt=- |
|
|
|
|
|
|
#4 |
|
.NUT
Join Date: May 05
Location: Sydney, Australia
Posts: 60,536
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Shell to a new browser to open a URL
Just a point of clarification. If IE is your default browser and you call Process.Start and pass it only a URL, its behaviour depends on the "Reuse windows for launching shortcuts" option on the Advanced tab of the Internet Options dialogue. If that option is ticked then a current window will used to display the new URL if one is open. If that option is not ticked then a new window will always be opened for the new URL whether there is already a window open or not.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs MSDN "How Do I?" Videos: VB | C# VBForums Database Development FAQ My CodeBank Submissions: VB | C# (ForumAccount has translated some of my VB submissions to C#) My Blog: Defining and Raising Custom Events | Manipulating GDI+ Drawings | Using Parameters in ADO.NET |
|
|
|
|
|
#5 |
|
"The" RedHeadedLefty
Join Date: Aug 05
Location: College Station, TX Preferred Nickname: Gig Current Mood: Just Peachy Turnons: String Manipulation
Posts: 4,484
![]() ![]() ![]() ![]() ![]() |
Re: Shell to a new browser to open a URL
I just tested process.start in my vb.net 2002... and FireFox opened ... my default browser
|
|
|
|
|
|
#6 |
|
Moderator.NET
Join Date: Nov 01
Location: NJ - USA (Near NYC)
Posts: 22,435
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Shell to a new browser to open a URL
and? that is normal functionality
__________________
Using VB.NET 2010/.NET 2.0 through 4.0 * Please mark you thread resolved using the Thread Tools above ![]() PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!! * If you found a post useful then please Rate it! Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup ZerosAndTheOne.com -=Matt=- |
|
|
|
|
|
#7 |
|
Frenzied Member
Join Date: Jun 03
Location: Ashby, Leicestershire.
Posts: 1,091
![]() ![]() |
Re: Shell to a new browser to open a URL
i suppose you could also use the default browser value thats stored in the registry under this key ...
HKEY_CLASSES_ROOT\htmlfile\shell\open\command ( the ' Default ' key ) to open your browser with the default rather than IE in that case i'd do something like this ... VB Code:
__________________
~ if a post is resolved, please mark it as [Resolved] protected string get_Signature(){return Censored;} ![]() [vbcode][php] please use code tags when posting any code [/php][/vbcode] |
|
|
|
|
|
#8 | |
|
New Member
Join Date: Jan 08
Posts: 3
![]() |
Re: Shell to a new browser to open a URL
I have a followup question to this, the URL I'd like to be able to browse to is different depending on the customer number the form is looking at...I have the unique URLS in a a field in my table..how do I tell this shell command to use *that* specific URL?
Quote:
|
|
|
|
|
|
|
#9 |
|
Fanatic Member
Join Date: Oct 02
Posts: 547
![]() |
Re: Shell to a new browser to open a URL
This is the code I use in my Login Password Manager (Go to Site Button) and
it opens a new browser instance for me: Code:
Dim p As New Process()
p.StartInfo.FileName = GetDefaultBrowser()
p.StartInfo.Arguments = targetURL
p.Start()
Friend Function GetDefaultBrowser() As String
Dim browser As String = [String].Empty
Dim key As Microsoft.Win32.RegistryKey = Nothing
Dim Quote As String = Chr(34)
Try
key = My.Computer.Registry.ClassesRoot.OpenSubKey("HTTP\shell\open\command", False)
' trim off quotes
browser = key.GetValue(Nothing).ToString().ToLower().Replace(Quote, "")
If Not browser.EndsWith("exe") Then
' get rid of everything after the 'exe'
browser = browser.Substring(0, browser.LastIndexOf(".exe") + 4)
End If
Finally
If key IsNot Nothing Then
key.Close()
End If
End Try
Return browser
End Function
|
|
|
|
|
|
#10 |
|
Addicted Member
Join Date: May 08
Posts: 133
![]() |
Re: Shell to a new browser to open a URL
Thanks kleinma it worked perfectly!
As an aside, is there a way to hide the default browser using this code? I am using it to set a cookie only but do not want it visible if possible. |
|
|
|
|
|
#11 |
|
Fanatic Member
Join Date: Jan 09
Posts: 555
![]() |
Re: Shell to a new browser to open a URL
Code:
Process.Start("explorer.exe", "www.google.com")
__________________
![]() ![]() - - - - - - - - - - - - - Website eDev Software On-Going Projects 1.Tinternet - - - - - - - - - - - - - My Useful Links:.NET Framework Class Library | [Internet Explorer Version]Internet Reconnecter | [Mozilla Firefox Version]Internet Reconnecter | Auto Clicker | 30 Minute Regex Tutorial | CodeBank(ALL):Simulate Mouse Click | HTML Viewer | EaseInstaller | Signs + Description | VB Code Snippet Maker | Read/Write .INI Files | Movable Form Without Titlebar | Check ifFirstRun | Create App Thread | Volume Control Class | Custom Wait Function | Emcranks Auto Updater | System-Wide Hotkeys [Virtual Key Codes] | Get Filename From Download URL | Zipping/Unzipping Using Shell32.dll | Import My.Settings From Previous Build | WebBrowser Control: Delete History | Simple Sound Recorder [mciSendString Commands] | App Trial Code | WebBrowser Control: Get Favicon.ico | Generate Random String | Manipulate Files Using Wildcards | Last edited by Emcrank; Jul 17th, 2010 at 11:47 AM. |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Jul 10
Posts: 26
![]() |
Re: Shell to a new browser to open a URL
Code:
Dim webAddress As String = "http://www.vbforums.com"
Process.Start(webAddress)
|
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|