Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell script to open multiple url's in ie browser

Been trying to open multiple url's in ie browser through powershell script

Currently my code is working In chrome browser, how can i achive the same in ie explorer

$urls=gc "C:actual path of the url folder\url.txt"
foreach($url in $urls){
    start-process chrome.exe $url

}

Can anyone help me on this?

like image 580
Abhilash Poojary Avatar asked Dec 18 '22 18:12

Abhilash Poojary


2 Answers

I think this can help you :

This next code open with default web browser :

$urls = @("https://stackoverflow.com/","https://www.google.com/","https://www.thomasmaurer.ch/2017/02/open-website-from-powershell/")

foreach($url in $urls){
    Start-Process $url
}

This next open in iexplorer :

$urls = @("https://stackoverflow.com/","https://www.google.com/","https://www.thomasmaurer.ch/2017/02/open-website-from-powershell/")

foreach($url in $urls){
    # Start-Process "C:\Program Files (x86)\Internet Explorer\iexplore.exe" $url
    Start-Process iexplore.exe $url
}

Look at thoses link : https://www.thomasmaurer.ch/2017/02/open-website-from-powershell/

**

  • EDIT multi tabs on InternetExplorer :

** Note in Internet Explorer the start process doesn't add new Url (at new tab) to existing instance off IE . If you want to open all urls in same instance off IExplorer you have to try other code and see thoses post :

Open tab in existing IE instance

https://superuser.com/questions/208883/using-powershell-to-open-several-tabs-on-start-up

like image 50
Sanpas Avatar answered Jan 12 '23 00:01

Sanpas


You can replace the part with "chrome.exe" in your code with iexplore and it should work.


EDIT: Since the original solution opened links in multiple windows, I have created an updated script that tries to open all the links in same browser window.

$IE = new-object -ComObject "InternetExplorer.Application"
$urls= gc "FILEPATH"
$count=1
foreach ($url in $urls){
    if ($count -eq 1){
        $IE.navigate($url,1)
    }
    else{
        $IE.navigate($url,2048)
    }
    $count++
}
like image 25
crappyprog Avatar answered Jan 12 '23 00:01

crappyprog