Internet explorer 当已有默认窗口打开时,如何在新IE窗口中打开IE选项卡

Internet explorer 当已有默认窗口打开时,如何在新IE窗口中打开IE选项卡,internet-explorer,batch-file,tabs,Internet Explorer,Batch File,Tabs,好吧,我正在处理一个BAT文件,我遇到了一个问题 这是我的BAT文件: @ECHO *************WELCOME BACK******************* @PAUSE @ECHO OFF START /d iexplore http://V.P.N url |||||this creates a window that has to stay opened for my V.P.N access @PAUSE START /d iexplore 1 STA

好吧,我正在处理一个BAT文件,我遇到了一个问题

这是我的BAT文件:

@ECHO *************WELCOME BACK*******************

@PAUSE 

@ECHO OFF 

START /d iexplore http://V.P.N url

|||||this creates a window that has to stay opened for my V.P.N access

@PAUSE 

START /d iexplore 1

START /d iexplore 2

||| these sites load as tabs which perfect
这个问题就在这一部分。我需要它做的是打开一个全新的IE窗口,随后的URL将作为选项卡在新窗口中打开,但是当我运行BAT时,它会打开一个新窗口,但是它会打开第一个IE窗口中的所有选项卡(vpn,工具1和2)

您知道如何将第二个IE窗口设置为默认窗口,以便将新选项卡加载到新窗口吗


这是针对IE8的。

我无法在windows 8上测试它,但这“应该”起作用,或者至少可以用作一个解决方案的框架

这是一个混合批处理/jscript文件。将其另存为
.cmd
.bat
并执行。根据需要进行调整

@if (@this==@isBatch) @then
@echo off

    rem search internet explorer
    for /f "tokens=2,*" %%a in ('
        reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE" /ve
        ^|find "REG_"
    ') do set "iexplore=%%b"


    rem Start the VPN instance 
    start "" "%iexplore%" -new http://www.example.com/vpn
    rem Let internet explorer initialize this instance
    timeout /t 2 > nul

    rem Start a new explorer window
    start "" "%iexplore%" -new http://www.example.com/mySite
    rem Let internet explorer initialize this instance
    timeout /t 2 > nul


    rem Now, load a new set of addresses into the last opened window
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite2"
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite3"
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite4"
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite5"

    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, navOpenNewForegroundTab, '_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);
@if (@this==@isBatch) @then
@echo off

    rem search internet explorer
    for /f "tokens=2,*" %%a in ('
        reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE" /ve
        ^|find "REG_"
    ') do set "iexplore=%%b"


    rem Start the VPN instance 
    start "" "%iexplore%" -new http://www.example.com/vpn
    rem Let internet explorer initialize this instance
    timeout /t 2 > nul

    rem Start a new explorer window
    start "" "%iexplore%" -new http://www.example.com/mySite
    rem Let internet explorer initialize this instance
    timeout /t 2 > nul


    rem Now, load a new set of addresses into the last opened window
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite2"
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite3"
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite4"
    cscript //nologo //e:jscript "%~f0" /url:"http://www.example.com/mySite5"

    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, navOpenNewForegroundTab, '_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);