Open multiple tabs in Internet Explorer (or Firefox) via command line
I was asked an interesting question today: how to open mutiple tabs in Internet Explorer from the command line?
It’s easy to open one page in IE via command line, but there’s no way to open multiple tabs. I went looking around and found a solution by Microsoft employee Tony Schreiner, via a small script:
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
It’s much easier to open multiple tabs in Firefox via command line, just specify multiple URLs and it figures out what to to:
$ firefox http://1st.url.here http://2nd.url.here http://3rd.url.here
The three URLs specified will each be opened in a tab. Fun, fun!