Partager via


IE Automation & Tabs

A comment to one of my other posts asked about how to launch IE and open several additional tabs.

IE7 does not support specifying multiple URLs on the command line, but another way to do this is to use IE Automation to launch IE as an out-of-proc COM server and then call methods such as IWebBrowser2::Navigate2. While you can do this using C++ or any language that supports COM, the easiest is to use Windows Scripting Host.

First, create a 'lanuchie.js' file using your favorite text editor, add the following, and save:

 var navOpenInBackgroundTab = 0x1000;
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.Navigate2("https://blogs.msdn.com");
oIE.Navigate2("https://blogs.msdn.com/tonyschr", navOpenInBackgroundTab);
oIE.Navigate2("https://blogs.msdn.com/oldnewthing", navOpenInBackgroundTab);
oIE.Navigate2("https://blogs.msdn.com/ericlippert", navOpenInBackgroundTab);
oIE.Visible = true;

Now from the command line you can do:

 wscript.exe launchie.js

to open IE, navigate the first tab, and then open three background tabs.

One caveat: due to some IE features such as Protected Mode you will sometimes observe that the links are opened in an existing IE window.

Comments

  • Anonymous
    January 19, 2007
    As we know, IE7 has two new features being multiple home pages and favorite groups. You can find information

  • Anonymous
    March 03, 2007
    The comment has been removed

  • Anonymous
    March 05, 2007
    The comment has been removed

  • Anonymous
    March 06, 2007
    Thanks for this script - wanted a way to automate IE to make it play the local news radio and open the newspapers for me at 7.45 am every day.  Works a treat.  Beautiful. Cheers from Sydney

  • Anonymous
    March 15, 2007
    Hi i managed to automate Internet Explorer 7 to open multiple site with js too :) I also managed to open multiple site in FireFix and Opera, and i built a nice Freeware that managing all your bookmarks and allows you to open multiple tabs in any browser you would like its called Magic Bookmarks v1.03 take a look: http://www.neverslair-blog.net/daniel-s-dev-corner/

  • Anonymous
    March 31, 2009
    From elsewhere in the collective.