Welcome to MSDN Blogs Sign in | Join | Help

Tony Schreiner's WebLog

Developer - IE | Windows | Graphics. Fighting complexity for 10 years and counting.

Syndication

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.

Published Friday, January 19, 2007 10:51 AM by tonyschr

Comments

# Opening IE via command line with multiple tabs @ Saturday, January 20, 2007 12:15 AM

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

Spyware Sucks

# re: IE Automation & Tabs @ Saturday, March 03, 2007 9:30 AM

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!

Bernie

# re: IE Automation & Tabs @ Monday, March 05, 2007 11:14 PM

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

Ohmster

# re: IE Automation & Tabs @ Tuesday, March 06, 2007 5:31 PM

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

John Benson

# re: IE Automation & Tabs @ Friday, March 16, 2007 2:42 AM

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/

Daniel

# 2009 Q1 link clearance: Microsoft blogger edition @ Tuesday, March 31, 2009 12:58 PM

From elsewhere in the collective.

The Old New Thing

New Comments to this post are disabled
Page view tracker