locked
Open IE and Navigate from VB.Net RRS feed

  • Question

  • Can anyone tell me how to open Internet Explorer and navigate to URLs from vb.net?

    When the user clicks a button on my windows form I would like it to navigate to a URL in Internet Explorer.  If there is already an IE window open, I would like it to reuse it.

    Something like this:

    If (IE is not open) then
      Open IE
    End If
    Navigate to URL

    Thanks

    Thursday, August 17, 2006 6:44 PM

Answers

  • System.Diagnostics.Process.Start("iexplore http://www.yoursite.com")

     

    Thursday, August 17, 2006 7:38 PM

All replies

  • System.Diagnostics.Process.Start("iexplore http://www.yoursite.com")

     

    Thursday, August 17, 2006 7:38 PM
  • That almost worked but it got me started, I had to change it to the following:

    System.Diagnostics.Process.Start("iexplore.exe", "http://www.yoursite.com")

    However, this opened a new window each time.
    I found that the following would reuse the browser, if available:

    System.Diagnostics.Process.Start("http://www.yoursite.com")

    Now, as a followup question...

    Is there anyway to close this browser window when I am done?

    Thanks!

    Friday, August 18, 2006 4:00 PM
  • yes...

    Create an instance of the process....

     

    Dim myProcess as new System.Diagnostics.Process()

     

    myProcess.StartInfo = new System.Diagnostics.ProcessStartInfo("iexplore")

    myProcess.Arguments = yourWebsite

    myProcess.Start()

     

    then to exit the process (kill)

     

    myProcess.Kill()

     

     

     

     

    Friday, August 18, 2006 4:08 PM
  • This allows me to close the window, but if I call it multiple times it doesn't use the same window.

    Once I have opened the window, is there a way to just pass it a new url?

    Thanks

     

    Friday, August 18, 2006 6:35 PM
  • not quite I believe, unless you get a handle of the window then do some Win32 call like SendMessage or something.

    The reason is because you are killing the process, which means it gets rid of it completely.

     

    I guess you could maybe do this, and see if it helps?

     

    if myProcess.HasExited = false then

       myProcess.StartInfo = new System.Diagnostics.ProcessStartInfo("yourWebsite")

       myProcess.Start()

    end if

     

     

    if this doesnt work, try setting the "CreateNoWindow" to false:

    myProcess.StartInfo.CreateNoWindow = false

    myProcess.StartInfo.FileName = yourWebsite

    myProcess.Start()

    Friday, August 18, 2006 6:37 PM
  • If the reason you need to open a web browser is just for a certain page, and the client or user will not need all the fancy features like bookmarks ect.  You can create your own form with a web browser control and pass the URL between the main from and the web browser form.
    Friday, August 18, 2006 6:44 PM
  • hey Just want to know how to open my html file that in Internet explorer  that is opened in my editor created in vb.net

     

    Tuesday, July 26, 2011 10:24 AM
  • It would be great if you could show us your code.

    you can open an html file in IE by spawning a process using the ProcessStart/ProcessStartInfo classes in the System.Diagnostics namespace and using the ProcessName as "iexplore" and the arguments as the path to your html file. Example:

     

    Dim psi as new System.Diagnostics.ProcessStartInfo("iexplore")

    psi.Arguments = "C:\MyHTMLFile.html"

    System.Diagnostics.Process.Start(psi)

     

     

     

     


    C# MVP (2007-2010) MS Vendor - MS All the way! Follower since 1995 MS Super Evangelist| MSDN Forums Moderator
    • Proposed as answer by ahmedilyas Tuesday, July 26, 2011 8:55 PM
    Tuesday, July 26, 2011 7:05 PM