2014-09-29 198 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/" 
相关问题