Launch IE tabs based on TXT file

Ask your Windows 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.
Locked
thatsameer
Posts: 18
Joined: Fri Aug 03, 2018 7:02 am

Launch IE tabs based on TXT file

Post by thatsameer » Mon Jan 21, 2019 3:38 am

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 937 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

User avatar
jvierra
Posts: 13736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Launch IE tabs based on TXT file

Post by jvierra » Mon Jan 21, 2019 4:01 am

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
Joined: Fri Aug 03, 2018 7:02 am

Re: Launch IE tabs based on TXT file

Post by thatsameer » Mon Jan 21, 2019 4:18 am

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 923 times
Using the same script on Chrome works as intended:
chrometxt.png
chrometxt.png (8.73 KiB) Viewed 923 times
I require this to work on IE

User avatar
jvierra
Posts: 13736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Launch IE tabs based on TXT file

Post by jvierra » Mon Jan 21, 2019 4:37 am

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

help foreach -online

User avatar
D.Leaman
Posts: 18
Joined: Thu Jan 10, 2019 4:21 pm

Re: Launch IE tabs based on TXT file

Post by D.Leaman » Fri Feb 01, 2019 9:42 am

This should do the trick:

Code: Select all

$URL = Get-Content C:\Users\xadmin\Documents\Dashboard\URL.txt
$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

User avatar
D.Leaman
Posts: 18
Joined: Thu Jan 10, 2019 4:21 pm

Re: Launch IE tabs based on TXT file

Post by D.Leaman » Fri Feb 01, 2019 10:32 am

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

User avatar
jvierra
Posts: 13736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Launch IE tabs based on TXT file

Post by jvierra » Fri Feb 01, 2019 10:41 am

Devin. The issue is about IE and not Google. The OP's Chrome code works fine.

Locked