# Opening multiple URLs in separate tabs in the same window

**URL:** <https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457>\
**Category:** PowerShell Help\
**Created:** [May 29, 2022, 3:17pm UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457 "2022-05-29T15:17:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Donut\_McSprinkle](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@Donut\_McSprinkle](https://forums.powershell.org/u/Donut_McSprinkle)\
**Post date:** [May 29, 2022, 3:17pm UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/1 "2022-05-29T15:17:53Z")

</div>

I’d like to run a script that opens multiple URLs in their own tabs in the same window in Internet Explorer.

Ok, so, when I run the following script, the URLs come up neatly as three tabs in a single window in Edge.

```auto
$urls = @("https://www.merriam-webster.com/","https://www.lexico.com/","https://www.wiktionary.org/")
foreach($url in $urls)
{
Start-Process msedge.exe $url
}

```

And when I run the script below (the only difference being that the process is now _ **chrome.exe** _), I get the same neat result in Chrome. Three tabs in the same window.

```auto
$urls = @("https://www.merriam-webster.com/","https://www.lexico.com/","https://www.wiktionary.org/")
foreach($url in $urls)
{
Start-Process chrome.exe $url
}

```

But when I run this script…

```auto
$urls = @("https://www.merriam-webster.com/","https://www.lexico.com/","https://www.wiktionary.org/")
foreach($url in $urls)
{
Start-Process iexplore.exe $url
}

```

… the URLs open up in three separate _windows_ in Internet Explorer.

I know it’s almost a moot point, since Internet Explorer is about to retire, but please indulge me. Is there a way to fix this script so that I can get the same results in Internet Explorer as I do in Edge or Chrome? Or do we just chalk it up to Explorer not being controllable that way?

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 29, 2022, 3:21pm UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/2 "2022-05-29T15:21:30Z")

</div>

Searching for “_internet explorer open new tab command line_” in Google brought up this as the first hit:

> <https://superuser.com/questions/601850/open-a-url-file-in-a-new-tab-of-existing-ie-window-from-command-line>

---

<div class="post-metadata">

**Author:** ![Donut\_McSprinkle](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@Donut\_McSprinkle](https://forums.powershell.org/u/Donut_McSprinkle)\
**Post date:** [May 29, 2022, 8:53pm UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/3 "2022-05-29T20:53:10Z")

</div>

> [@Olaf](#):
>
> Searching for “ _internet explorer open new tab command line_ ” in Google brought up this as the first hit:
> 
> [Open a URL file in a new tab of existing IE window from command line - Super User](https://superuser.com/questions/601850/open-a-url-file-in-a-new-tab-of-existing-ie-window-from-command-line)

Well, golly, that sure took me down a rabbit hole for a few hours. But it paid off because I made it work. 🧐 🤓 Behold…

```auto
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true

$urls = @("www.merriam-webster.com","www.lexico.com","www.wiktionary.org")
$bFirstTab = $true

foreach($url in $urls)
{
    if($bFirstTab)
    {
	$ie.navigate2($url)
	$bFirstTab = $false
    }
    else
    {
	$ie.navigate2($url, 0x0800)
    }
}

```

Credit where credit is due, and for anyone who is interested, check out this site for further explanation: [Powershell Internet Explorer Automation Basics](https://www.fl0re.com/2019/10/23/powershell-internet-explorer-automation-part-1/)

Also, check out the documentation for ComObjects here: [Creating .NET and COM objects - PowerShell | Microsoft Learn](https://docs.microsoft.com/en-us/powershell/scripting/samples/creating-.net-and-com-objects--new-object-?view=powershell-7.2)

Before today I had no idea what a _ComObject_ was, I had no idea what the _navigate2 method_ was, and I had no idea what a _flag_ was.

The thing that I still find irritating is that I can’t find any documentation on what the flag values actually mean, or the logic from which they are derived. I just had to take for granted that _ **0x0800** _ is the value that will make the URL open in a new tab. But, I mean, why? Like, why is the _x_ sitting right there between those two 0s, for example?

Anyway, thank you for steering me in the right direction (even if in a couple of weeks this solution will be purely academic). 👍

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 29, 2022, 11:52pm UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/4 "2022-05-29T23:52:22Z")

</div>

> [@Donut\_McSprinkle](#):
>
> But it paid off because I made it work.

Hey hey … cool. 👍🏽 👏🏽🥳 And thanks for sharing your solution. 🤟🏽

> [@Donut\_McSprinkle](#):
>
> The thing that I still find irritating is that I can’t find any documentation on what the flag values actually mean

Since creating a good, complete and comprehensive documentation is a lot of work on the one side and no glory in it on the other it’s very often neglegted.

> [@Donut\_McSprinkle](#):
>
> I just had to take for granted that _ **0x0800** _ is the value that will make the URL open in a new tab.

Of course I do not know the meaning of the flag but an “x” at this position of a number means that it is a hex number. So in decimal format it would be 2048. 😉

---

<div class="post-metadata">

**Author:** ![Donut\_McSprinkle](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@Donut\_McSprinkle](https://forums.powershell.org/u/Donut_McSprinkle)\
**Post date:** [May 30, 2022, 12:26am UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/5 "2022-05-30T00:26:19Z")

</div>

> [@Olaf](#):
>
> Of course I do not know the meaning of the flag but an “x” at this position of a number means that it is a hex number. So in decimal format it would be 2048. 😉

Oh my goodness, thank you! 😲 I kept seeing those two numbers in reference to the same method parameter and spent much too long wondering if one was for an older version of Internet Explorer or… or something. 😭 Good to know!

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 30, 2022, 12:30am UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/6 "2022-05-30T00:30:20Z")

</div>

You’re very welcome. I’m glad it helped. 👍🏽

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/opening-multiple-urls-in-separate-tabs-in-the-same-window/19457/7 "2024-05-16T20:17:51Z")

</div>


