Abh*_*ary 4 windows powershell internet-explorer
一直试图通过 powershell 脚本在 ie 浏览器中打开多个 url
目前我的代码正在 chrome 浏览器中工作,我如何在 ie explorer 中实现相同的功能
$urls=gc "C:actual path of the url folder\url.txt"
foreach($url in $urls){
start-process chrome.exe $url
}
Run Code Online (Sandbox Code Playgroud)
谁可以帮我这个事?
我认为这可以帮助你:
下一个代码使用默认 Web 浏览器打开:
$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
}
Run Code Online (Sandbox Code Playgroud)
接下来在 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
}
Run Code Online (Sandbox Code Playgroud)
看看那些链接:https ://www.thomasmaurer.ch/2017/02/open-website-from-powershell/
**
** 请注意,在 Internet Explorer 中,启动过程不会将新的 Url(在新选项卡上)添加到 IE 之外的现有实例。如果您想在 IExplorer 的同一实例中打开所有网址,您必须尝试其他代码并查看这些帖子:
https://superuser.com/questions/208883/using-powershell-to-open-several-tabs-on-start-up
您可以使用 iexplore 替换代码中带有“chrome.exe”的部分,它应该可以工作。
编辑:由于原始解决方案在多个窗口中打开链接,我创建了一个更新的脚本,尝试在同一浏览器窗口中打开所有链接。
$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++
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18259 次 |
| 最近记录: |