Open tabs in internet explorer with cmd

前端 未结 4 584
醉酒成梦
醉酒成梦 2021-01-16 14:51

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

相关标签:
4条回答
  • 2021-01-16 15:28

    Finally got it work in IE! with VB script!! save this in .vbs file:

    Const navOpenInBackgroundTab = &H1000
    
    site1 = "(write your site here)"
    site2 = "(write your site here)"
    site3 = "(write your site here)"
    
    Set oIE = CreateObject("InternetExplorer.Application")
    oIE.Visible = True
    oIE.Navigate2 site1
    oIE.Navigate2 site2,navOpenInBackgroundTab
    oIE.Navigate2 site3,navOpenInBackgroundTab
    
    Set oIE = Nothing
    
    0 讨论(0)
  • 2021-01-16 15:31

    I have provided some code for .bat files that should achieve the functionality you are looking for.

    To use: copy the code to a Notepad window and save as MyFile.bat or some other filename ending in .bat and double-click the file to run.

    To open Internet Explorer with 1 window and 3 separate tabs:

    :: n pings take n-1 seconds
    start "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    ping 127.0.0.1 -n 2 > nul
    start "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    ping 127.0.0.1 -n 2 > nul
    start "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    

    To open Internet Explorer with 1 window and 3 separate tabs (alternative):

    :: timeout n lasts between n-1 and n seconds
    start "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    timeout 2
    start "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    timeout 2
    start "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    

    To open Internet Explorer with 3 separate windows:

    "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    "C:\Program Files\Internet Explorer\iexplore.exe" "https://www.google.com/"
    
    0 讨论(0)
  • 2021-01-16 15:33

    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);
    
    0 讨论(0)
  • 2021-01-16 15:45
    START "" "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://marathon:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345"
    

    ?

    /d switch is for the starting directory (which I think is not relevant in your case).The first parameter is the title which in your case will be "C:\Program Files (x86)\Internet Explorer\iexplore.exe" and for the link left the default program as the open program is not really pointed.

    0 讨论(0)
提交回复
热议问题