Page 1 of 1

Launch IE tabs based on TXT file

Posted: Mon Jan 21, 2019 3:38 am
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 1784 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

Re: Launch IE tabs based on TXT file

Posted: Mon Jan 21, 2019 4:01 am
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.

Re: Launch IE tabs based on TXT file

Posted: Mon Jan 21, 2019 4:18 am
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 1770 times
Using the same script on Chrome works as intended:
chrometxt.png
chrometxt.png (8.73 KiB) Viewed 1770 times
I require this to work on IE

Re: Launch IE tabs based on TXT file

Posted: Mon Jan 21, 2019 4:37 am
by jvierra
Just read them from the text file and add them to the command in a loop.

help foreach -online

Re: Launch IE tabs based on TXT file

Posted: Fri Feb 01, 2019 9:42 am
by D.Leaman
This should do the trick:
  1. $URL = Get-Content C:\Users\xadmin\Documents\Dashboard\URL.txt
  2.  
  3. $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.

Re: Launch IE tabs based on TXT file

Posted: Fri Feb 01, 2019 10:32 am
by D.Leaman
I can now confirm that if you have Chrome open and run the above code, it will open the pages in new tabs.

Re: Launch IE tabs based on TXT file

Posted: Fri Feb 01, 2019 10:41 am
by jvierra
Devin. The issue is about IE and not Google. The OP's Chrome code works fine.