You are currently offline, waiting for your internet to reconnect

How to programmatically start the default Internet Browser by using Visual Basic .NET or Visual Basic 2005

This article was previously published under Q305705
This article has been archived. It is offered "as is" and will no longer be updated.
For a Microsoft Visual C# .NET version of this article, see 305703.
For a Microsoft Visual C++ .NET version of this article, see 307382.


This article demonstrates how to start the default Internet browser.

back to the top


  • Microsoft Visual Studio .NET or Microsoft Visual Studio 2005
back to the top

Specify the URL, FTP, or File to Open

You can specify a URL, a file, or an FTP address. All three of these assignments are valid:
    Dim target As String = ""    Dim target As String = ""    Dim target As String = "C:\Program Files\Microsoft Visual Studio\INSTALL.HTM"				
back to the top

Use the Process Class Start Method to Start the Browser

The Process class contains a shared Start method. Because this is a shared method, you can call Start without having an instance of a Process class.
back to the top

Provide Exception Handling

Because you take advantage of the default UseShellExecute property when you call the Start method, you do not have to explicitly query the registry to determine which browser is the default. However, if you use this approach on a computer that does not have a browser installed, an exception occurs. This exception must be caught so that the appropriate action can be taken. This example explicitly traps for an error that is generated when the necessary registry key is not found and indicates that no browser is installed. In addition, a general exception handler is provided for other errors that may occur. The try...catch block is demonstrated in the complete code listing.

back to the top

Complete Code Sample

    Dim target As String = ""    'Do not use more than one assignment at a time.    'This also works with FTP.    'Dim target As String = ""    'This also works with a file.    'Dim target As String = "C:\Program Files\Microsoft Visual Studio\INSTALL.HTM"         Try         System.Diagnostics.Process.Start(target)     Catch noBrowser As System.ComponentModel.Win32Exception _         When noBrowser.ErrorCode = -2147467259            MessageBox.Show(noBrowser.Message)     Catch other As System.ComponentModel.Win32Exception         MessageBox.Show(other.Message)     End Try				
back to the top


This code is highly dependent on the application-file type associations in the HKEY_CLASSES_ROOT hive of the registry. This can lead to unexpected results and exceptions if the registry is damaged. In addition, file types and extensions may also be associated with applications other than the browser. For example, HTM or HTML files may be associated with Web development software instead of the browser.

back to the top


For more information about the Process class, see the following .NET Framework Class Library documentation:back to the top
launch try-catch

Article ID: 305705 - Last Review: 02/28/2014 04:29:33 - Revision: 3.3

Microsoft Visual Basic 2005, Microsoft Visual Basic .NET 2003 Standard Edition, Microsoft Visual Basic .NET 2002 Standard Edition

  • kbnosurvey kbarchive kbvs2005applies kbvs2005swept kbhowtomaster KB305705