how to write batch file to start ie with several tabs

Dani AI

Generated

Short follow-up to : launching iexplore.exe repeatedly (the START lines shown earlier) tends to create separate IE windows or processes depending on user settings. If the goal is "one IE window with multiple tabs" scriptably, use Internet Explorer automation (the COM InternetExplorer.Application object) and the Navigate/Navigate2 flags that request "open in new tab." (learn.microsoft.com)

PowerShell example (opens first URL in the main window, then opens the rest as new tabs):

$navOpenInNewTab = 2048
$navBg = 4096

$urls = @('https://example.com','https://example.org','https://example.net')

$ie = New-Object -ComObject InternetExplorer.Application
$ie.Navigate2($urls[0])
foreach ($u in $urls[1..($urls.Count-1)]) {
    $ie.Navigate2($u, $navOpenInNewTab)
}
$ie.Visible = $true

The numeric flags above come from IE's BrowserNavConstants; Navigate2 opens tabs asynchronously and does not return an object reference for the newly created tab (so you can't immediately control that new tab from the same object). (learn.microsoft.com)

If you need a plain .bat wrapper, call PowerShell from the batch file (or save the script as a .ps1 and invoke it with powershell.exe -NoProfile -ExecutionPolicy Bypass -File ...). PowerShell examples for driving the IE COM object are well established. (devblogs.microsoft.com)

Cautions: tab creation depends on the browser's tabbed-browsing settings and group policy, and behavior may vary on modern Windows because Internet Explorer desktop has been retired; Microsoft recommends moving to Edge and using IE mode for legacy sites. For long-term automation, prefer a supported browser/automation stack (Edge/Chromium WebDriver or Selenium) rather than relying on IE. (learn.microsoft.com)

In Internet Explorer, Open 3 tabs (or as many as you like). Go to your 3 favorite pages. Then click Tools > Internet Options > Click Use Current > Click Apply > Click OK.

Close IE and reopen it, and you will have your 3 pages starting at once.

Its possible to create a batch for IE, but it won't open 3 tabs, only 3 instances of IE.

Save as IE.bat:

START "" "C:\Program Files\Internet Explorer\iexplore.exe" http://www.daniweb.com
START "" "C:\Program Files\Internet Explorer\iexplore.exe" 
START "" "C:\Program Files\Internet Explorer\iexplore.exe" http://mail.google.com
CLS
EXIT

Here's a VB script to do what you want:

Imports Microsoft.Win32
Imports System.Environment

Public Class Form1
Private startPage As String
Private oPages() As String
Private regKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\Main", True)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
startPage = regKey.GetValue("Start Page")
oPages = regKey.GetValue("Secondary Start Pages")

regKey.SetValue("Start Page", "http://mail.google.com")
regKey.SetValue("Secondary Start Pages", New String() {"http://www.daniweb.com", "http://www.michaelmknight.co.uk"}, RegistryValueKind.MultiString)
Process.Start("iexplore")
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
regKey.SetValue("Start Page", startPage)
If oPages Is Nothing Then
regKey.DeleteValue("Secondary Start Pages")
Else
regKey.SetValue("Secondary Start Pages", oPages, RegistryValueKind.MultiString)
End If
End Sub
End Class

You can also also enter this direct to the Registry (this does the same as the first solution):

For primary homepage:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page

For secondary multistart pages:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Secondary Start Pages

Use a new line as a separator.

Also, you must have open all pages set in the registry: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TabbedBrowsing\OpenAllHomePages

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.