我想用 PowerShell 自动化 InternetExplorer 在我们的 Intranet 中打开一个站点(受信任的站点 | 保护模式:关闭)
当我执行我的代码时,IE 打开了 Intranet 站点,但对 $ie 对象的引用丢失了。
错误: 调用的对象已与其客户端断开连接。(来自 HRESULT 的异常:0x80010108 (RPC_E_DISCONNECTED))
我怎样才能解决这个问题?(不能以管理员身份运行 IE)
$ie = New-Object -ComObject InternetExplorer.Application
$ie.visible = $true
$ie.Navigate($url)
$ie
我的解决方法,但不是很好:
& "C:\Program Files\Internet Explorer\iexplore.exe" $urls
Start-Sleep 5
$shell = New-Object -com Shell.Application
$ie = @($shell.Application.Windows())| Where-Object { $_.LocationUrl -like "*$urls*" }
$ie.Navigate($url2)