I want to make a cmd batch file that opens 3 tabs in internet explorer window Doesnt matter to me if there is already internet explorer window open or not I have this comman
This uses a hybrid batch file (save with .cmd
extension). Tested in XP, but you will have to test in your system.
@if (@this==@isBatch) @then
@echo off
rem search internet explorer
for /f "tokens=1,* delims=_" %%a in ('
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE" /ve
^|find "REG_"
') do for /f "tokens=1,*" %%c in ("%%~b") do set "iexplore=%%d"
rem Start first window instance
start "" "%iexplore%" -new "http://marathon:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345"
rem Let internet explorer initialize this instance
ping -n 6 localhost > nul
rem Now, load a new set of addresses into the last opened window
cscript //nologo //e:jscript "%~f0" /url:"http://sparta:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345"
cscript //nologo //e:jscript "%~f0" /url:"http://sparta:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345"
exit /b
@end //== javascript zone =======================================================
// Values to be used in the Navigate() method
var navOpenInNewTab = 0x0800
, navOpenInBackgroundTab = 0x1000
, navOpenNewForegroundTab = 0x10000;
// Retrieve command line arguments
var url = WScript.Arguments.Named.Item("url");
// Instantiate component to get access to shell
var shellApplication = new ActiveXObject('Shell.Application');
// Retrieve the last window
var windows = new Enumerator(shellApplication.Windows());
var w = null;
while (!windows.atEnd()){w = windows.item(); windows.moveNext()};
// If a window is found, use this window to open the url in a new tab,
// else create a iexplore instance to load the url
if (w){
w.Navigate(url, navOpenInBackgroundTab, '_blank');
} else {
with (new ActiveXObject('WScript.Shell')){
Run('"'
+ RegRead('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE\\')
+ '" -new "' + url + '"'
)
}
};
// Let everything initialize before exit
WScript.Sleep(500);