2015-10-03 100 views
1

我想創建一個批處理腳本,在iexplorer(我需要使用IE)中打開2個網站。在一個Internet Explorer窗口中打開多個選項卡

問題是,網址在單獨的IE窗口中打開。
是否有可能在1個窗口中只有2個選項卡?

taskkill /im iexplore.exe /f 
taskkill /t /f /im chrome.exe 
taskkill /t /f /im communicator.exe 
ping 127.0.0.1 -n 4 
start iexplore.exe http://site1 
start iexplore.exe http://site2 
start communicator.exe 
+0

的PowerShell:http://superuser.com/questions/601850/open-a-url-file-in-a-new-tab-of-existing-ie-window-from-command-line/ – beatcracker

+0

@beatcracker,在我的回答中已經提到過。 – wOxxOm

回答

1

使用VBScript代碼開始新InternetExplorer.ApplicationnavOpenInNewTab = 2048標誌打開使用navigate2方法標籤:

@echo off 
findstr /r /c:"^::[^ ]" "%~dpnx0" > "%temp%\openIEtab.vbs" 
cscript //b //nologo "%temp%\openIEtab.vbs" 
del "%temp%\openIEtab.vbs" 

::set IE = CreateObject("InternetExplorer.Application") 
::IE.visible = true 
::IE.navigate2 "google.com" 
::IE.navigate2 "bing.com", 2048 

也有PowerShell的解決方案(example)。

0

嘗試在您嘗試打開的第一個網站之後立即添加超時,就像這樣。超時將等待/T之後設置的任何秒數,這可能是您嘗試使用ping命令完成的操作,除非您需要每次ping特定地址。

taskkill /im iexplore.exe /f 
taskkill /t /f /im chrome.exe 
taskkill /t /f /im communicator.exe 
ping 127.0.0.1 -n 4 
start iexplore.exe http://site1 
TIMEOUT>NUL /T 3 /NOBREAK 
start iexplore.exe http://site2 
start communicator.exe 
+0

它不能解決問題,因爲IE始終在新窗口中從命令行打開URL。這就是爲什麼vbscript/powershell是必需的。 – wOxxOm

相關問題