How to open multiple tabs in IE8 from batch file

batch filebrowser-tabsinternet-explorer-8

Upon searching for an answer to this question, I stumbled upon an almost identical question on this site, to which someone answered:

"For launching multiple URLs in tabs in a single IE window, use the following script:

var navOpenInBackgroundTab = 0x1000;  
var objIE = new ActiveXObject("InternetExplorer.Application");  
objIE.Navigate2("site1");  
objIE.Navigate2("site2", navOpenInBackgroundTab);  
objIE.Navigate2("site3", navOpenInBackgroundTab);  
objIE.Visible = true;

Save as StartIE.js, then either double-click in Windows Explorer, or use wscript.exe StartIE.js at the command prompt to launch."

When I run StartIE.js, I get and error from "Windows Script Host" that says:

Script: [file address]  
Line: 4  
Char: 1  
Error: Unspecified error  
Code: 80004005  
Source: (null)

Would anyone kindly point out what I'm doing wrong?

Best Answer

This should work (save as a .vbs file):

Const navOpenInBackgroundTab = &H1000

site1 = "site1.com"
site2 = "site2.com"
site3 = "site3.com"

Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oIE.Navigate2 site1
oIE.Navigate2 site2,navOpenInBackgroundTab
oIE.Navigate2 site3,navOpenInBackgroundTab

Set oIE = Nothing