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(“http://blogs.msdn.com”);
oIE.Navigate2(“http://blogs.msdn.com/tonyschr”, navOpenInBackgroundTab);
oIE.Navigate2(“http://blogs.msdn.com/oldnewthing”, navOpenInBackgroundTab);
oIE.Navigate2(“http://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 (6)

  1. As we know, IE7 has two new features being multiple home pages and favorite groups. You can find information

  2. Bernie says:

    Perfect!

    This was exactly was I’ve been looking for. I never occured to me that it might be possible if you created an instance in a script using com. I looked for command line arguments that would support starting new tabs within IE7 but never got it to work. This does on the other hand. Thank you very much!

  3. Ohmster says:

    Could you please tell the location of where the add-on information is kept? I had 3 Trojan dlls being loaded with IE, disabled and then removed the offending dll files, but they still show up as add-ons. I even swept the registry to remove all traces of the offending dll add-ons. Is there any way to edit what is shown as add-ons for IE?

    In other words, how to you actually remove an add-on aside from just disabling it?

    Thank you if you can figure it out.

    ohmster at ohmster dot com

  4. John Benson says:

    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

  5. Daniel says:

    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/

  6. From elsewhere in the collective.