• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Automating Internet Explorer with C#.net

How can I programmatically start up IE and navigate to a specific URL using C#?
0
cvfn
Asked:
cvfn
  • 3
  • 2
  • 2
  • +1
1 Solution
 
praneethaCommented:
r u talking about windows or web application?
0
 
cvfnAuthor Commented:
Windows

Thanks,
Melody
0
 
praneethaCommented:
System.Diagnostics.Process.Start("IExplore.exe", "www.google.com");
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
cvfnAuthor Commented:
Thanks you for the quick reply. Can I access IE as a com object after starting it this way?

Melody
0
 
praneethaCommented:
http://www.codeproject.com/csharp/runninginstanceie.asp

see if that helps...i am not much of a windows person

0
 
CrazyIvan007Commented:
Start InternetExplorer (as said from praneetha), then use AxSHDocVw and MSHTML to access the WebBrowser

SHDocVw.InternetExplorer browser = null;
string filnam;
 
SHDocVw.ShellWindows shellWindows =      new SHDocVw.ShellWindowsClass();
   
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
      filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
 
      if (filnam.Equals("iexplore"))
      {
                     browser = ie;
                               object o = null;
                               browser.Navigate("http://www.yourpage.com/", ref o, ref o, ref o, ref o);
                               break;
      }
}

For this you have to set References to AxSHDocVw, SHDocVw and MSHTML. To get more informations about how to access the browser component look at

http://www.codeproject.com/csharp/webbrowser.asp
0
 
zstafaCommented:
1. Open a new windows app
2. drag a button on to the form
3. Double click on it
4. Paste this into it.

                        object o = null;

                        SHDocVw.InternetExplorer ie = new
                              SHDocVw.InternetExplorerClass();

                        IWebBrowserApp wb = (IWebBrowserApp) ie;
                        wb.Visible = true;

                        wb.Navigate("www.google.com", ref o, ref o, ref o, ref o);


5. Right click on references and click add the SHDocVw.dll reference in windows/system32
6.make sure to add "Using SHDocvw;"    at the top

0
 
zstafaCommented:
Sorry what do you want to do with the IE window after you access it?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now