无法使用InternetExplorer.Application对象? [英] Can't use InternetExplorer.Application object?

查看:529
本文介绍了无法使用InternetExplorer.Application对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的代码文件,可以在PC上正常工作.我把它带到另一个,然后把它弄坏了.我使用了此代码段,输出只是空白,没有从对象中得到任何东西.浏览器确实会加载页面.

I have an entire code file that works flawlessly on a PC. I brought it over to another one, and it busted. I used this snippet, and the output is just blank, it's not getting anything from the object. The browser does load the page though.

# Create the IE com object 
"Lauching IE process..."
$ie = new-object -com InternetExplorer.Application 
$ie.visible = $true
# Navigate to the login page
"Opening $loginPage"
$ie.navigate($loginPage) 
"Waiting for page to load..."
# Wait for the page to finish loading 
do {sleep 2} until (-not ($ie.Busy)) 
sleep 2
$ie.document.body.innerHTML

我找到了一些以Admin等身份运行的IE安全模型的引用,并对其进行了一些修改.

I found some references to IE security models, running as Admin, etc, and fiddled with it a bit.

    如果我以管理员身份运行,
  • 脚本不起作用
  • 我已尽可能禁用IE安全性
  • 从IE 11降级为IE 9
  • Script doesn't work if I run it as Administrator
  • I've disabled as much IE security as possible
  • Downgraded from IE 11 to IE 9

还是没有运气.

有什么建议吗?

谢谢!

推荐答案

好的,我最终解决了这个问题.根据这篇文章:

Okay I ended up solving the issue. Based on this post :

Powershell System .__ ComObject.document属性不再适用于IE 9

我也注意到了

$ie.document | Get-Member

在损坏的计算机上显示了一个COM对象guid,而在正常计算机上显示了mshtml.好的机器确实确实安装了Office.我复制了

Showed a COM object guid on the broken machine, and mshtml on the good machine. The good machine did indeed have Office installed. I copied

C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\microsoft.mshtml.dll

到坏掉的机器.然后在脚本的顶部添加了

to the broken machine. Then at the top of my script I added

Add-Type -Path "C:\dll\Microsoft.mshtml.dll"

宾果游戏,脚本现在可以按预期工作!

And bingo, the script now works as expected!

这篇关于无法使用InternetExplorer.Application对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆