?
Solved

Automating Internet Explorer with C#.net

Posted on 2004-10-01
8
Medium Priority
?
456 Views
Last Modified: 2008-01-09
How can I programmatically start up IE and navigate to a specific URL using C#?
0
Comment
Question by:cvfn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 12203487
r u talking about windows or web application?
0
 

Author Comment

by:cvfn
ID: 12203500
Windows

Thanks,
Melody
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12203531
System.Diagnostics.Process.Start("IExplore.exe", "www.google.com");
0
Technology Partners: 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!

 

Author Comment

by:cvfn
ID: 12203775
Thanks you for the quick reply. Can I access IE as a com object after starting it this way?

Melody
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12203821
http://www.codeproject.com/csharp/runninginstanceie.asp

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

0
 
LVL 1

Expert Comment

by:CrazyIvan007
ID: 12203888
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
 
LVL 3

Accepted Solution

by:
zstafa earned 1000 total points
ID: 12205932
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
 
LVL 3

Expert Comment

by:zstafa
ID: 12205942
Sorry what do you want to do with the IE window after you access it?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question