Internet explorer 如何从Powershell访问Internet Explorer运行实例的经典Internet Explorer COM自动化对象?
如何访问Internet Explorer运行实例的经典Internet Explorer COM自动化对象?也就是说,如果在多个窗口中打开Internet Explorer,如何从Powershell中将与其中一个窗口对应的COM对象与Powershell中的变量相关联?我最近一次这样做是通过get process获得进程“iexplore”和“ieuser”。通常,要获得对现有对象上COM接口的访问权,可以使用running object表。不幸的是,InternetExplorer没有在运行的对象表中注册自己,但是,这为我们提供了一些有用的Google搜索结果 例如,通过谷歌搜索“running object table”“internet explorer”找到了我,它提供了一个(VBScript?)示例,演示了ShellWindows对象的使用 此示例到PowerShell脚本的快速“n dirty”(无错误检查!)翻译为:Internet explorer 如何从Powershell访问Internet Explorer运行实例的经典Internet Explorer COM自动化对象?,internet-explorer,dom,com,powershell,Internet Explorer,Dom,Com,Powershell,如何访问Internet Explorer运行实例的经典Internet Explorer COM自动化对象?也就是说,如果在多个窗口中打开Internet Explorer,如何从Powershell中将与其中一个窗口对应的COM对象与Powershell中的变量相关联?我最近一次这样做是通过get process获得进程“iexplore”和“ieuser”。通常,要获得对现有对象上COM接口的访问权,可以使用running object表。不幸的是,InternetExplorer没有在运
$shellapp = New-Object -ComObject "Shell.Application"
$ShellWindows = $shellapp.Windows()
for ($i = 0; $i -lt $ShellWindows.Count; $i++)
{
if ($ShellWindows.Item($i).FullName -like "*iexplore.exe")
{
$ie = $ShellWindows.Item($i)
break
}
}
$ie.navigate2("http://stackoverflow.com")
我真的很想使用JScript来实现这一点。你知道有什么好的资源吗?