Launch IE tabs based on TXT file

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
thatsameer
Posts: 18
Last visit: Thu Apr 18, 2019 7:07 am

Launch IE tabs based on TXT file

Post by thatsameer »

Hi,

Using powershell to launch a browser and open a defined set of URLs from a notepad:

$url = Get-Content C:\Users\xadmin\Documents\Dashboard\URL.txt
Start-Process -FilePath "chrome.exe" -ArgumentList $url

This is the contents of the txt file:
notepadtxt.png
notepadtxt.png (3.93 KiB) Viewed 4047 times
This works perfectly and as expected on every browser apart from Internet Explorer.

I must use IE for my task otherwise I would have used Chrome.

Replace "chrome.exe" with "iexplore.exe", IE doesn’t open the URL lines in new tabs but thinks its ones big line of URL.

I've tried adding semi-colon after the URLs in the notepad but IE still places the whole txt file into one tab.

Pls help
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Launch IE tabs based on TXT file

Post by jvierra »

Internet Explorer has a command line switch to do this.
or
Start-Process 'http://www.google.com'

Specifying the URL to start will open a new tab in the currently running IE browser.
thatsameer
Posts: 18
Last visit: Thu Apr 18, 2019 7:07 am

Re: Launch IE tabs based on TXT file

Post by thatsameer »

Hi,

Thanks for the reply.

This doesn't solve my issue.

The issue is, I want to specify the URLs in a text file as the screenshot above. I do not want to hardcode the URLs in the script - only to point to a txt file containing the URLs so can modify freely.

However, asking IE to open with the URLs in the text file instead of going into each tab, instead it makes it one long URL:
ietxt.png
ietxt.png (7.98 KiB) Viewed 4033 times
Using the same script on Chrome works as intended:
chrometxt.png
chrometxt.png (8.73 KiB) Viewed 4033 times
I require this to work on IE
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Launch IE tabs based on TXT file

Post by jvierra »

Just read them from the text file and add them to the command in a loop.

help foreach -online
4lch4_ExtraTxt
Posts: 21
Last visit: Sat Feb 24, 2024 5:20 am
Has voted: 2 times

Re: Launch IE tabs based on TXT file

Post by 4lch4_ExtraTxt »

This should do the trick:
  1. $URL = Get-Content C:\Users\xadmin\Documents\Dashboard\URL.txt
  2. $URL | ForEach-object { Start-Process -FilePath "chrome.exe" -ArgumentList $_ }
You get your URL data from the file, pipe it to ForEach-Object as JVierra recommended, and then execute the Start-Process cmdlet against each URL.

I'm not sure this will open them all in one Chrome instance though, it may open them in separate windows, I'm unable to verify at the moment.
J.B. Hunt
Devin Leaman
Devin.Leaman@jbhunt.com
4lch4_ExtraTxt
Posts: 21
Last visit: Sat Feb 24, 2024 5:20 am
Has voted: 2 times

Re: Launch IE tabs based on TXT file

Post by 4lch4_ExtraTxt »

I can now confirm that if you have Chrome open and run the above code, it will open the pages in new tabs.
J.B. Hunt
Devin Leaman
Devin.Leaman@jbhunt.com
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Launch IE tabs based on TXT file

Post by jvierra »

Devin. The issue is about IE and not Google. The OP's Chrome code works fine.
This topic is 5 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked