2014-09-29 187 views
0

我想製作一個cmd批處理文件,在Internet Explorer窗口中打開3個標籤 如果已經有Internet Explorer窗口打開,對我無關 我有這個commant,但它打開在Chrome的標籤(我的默認瀏覽器,不要想改變它。)用cmd在Internet Explorer中打開標籤

START /d iexplore.exe "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://marathon:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345" 
START /d iexplore.exe "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://sparta:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345" 
START /d iexplore.exe "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://sparta:7040/console/jsp/login/j_security_check?j_username=wc&j_password=12345" 

請幫助:)

回答

1

終於在IE中工作了!用VB腳本!它保存在.vbs文件:

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
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開關是用於起始目錄(我認爲這與你的情況無關)。第一個參數是標題,在你的情況下將是"C:\Program Files (x86)\Internet Explorer\iexplore.exe"並且鏈接保留默認程序,因爲打開的程序不是真的很尖銳。

+0

測試它,但它打開Internet Explorer的3個不同的窗口。我想用3個不同的標籤打開一個Internet Explorer窗口 – Erez 2014-09-29 11:58:15

+0

@Erez - 檢查你的Internet Explorer設置 - > http://answers.microsoft.com/en-us/ie/forum/ie8-windows_other/internet-explorer-is -opening-new-windows-instead/d18f1b43-e79e-40a4-ac5f-d1b53098d243 – npocmaka 2014-09-29 12:06:06

+0

不工作。你的代碼打開3個不同的窗口,而不是標籤。測試2臺電腦,IE9和IE11 – Erez 2014-09-30 06:42:33

0

這使用混合批處理文件(另存爲.cmd擴展名)。測試在XP中,但你將不得不在你的系統中測試。

@if (@[email protected]) @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

我已經提供了應該達到你正在尋找的功能.bat文件的一些代碼。

使用方法:將代碼複製到記事本窗口並另存爲MyFile.bat或以.bat結尾的其他文件名,然後雙擊要運行的文件。

若要用1個窗口和3個獨立的凸片打開Internet Explorer:

:: 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/" 

要打開的Internet Explorer 1個窗口和3個獨立的翼片(備選):

:: 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/" 

要與打開Internet Explorer 3個獨立的窗口:

"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/" 
相關問題