Internet explorer Vbscript:如何在管理模式下列出所有Internet Explorer窗口
我需要一些关于在Windows7下使用InternetExplorer11的vbscript的帮助。我发现,当创建两个(或更多)IE对象时,当进入管理模式时,只有第一个对象可以在Internet explorer Vbscript:如何在管理模式下列出所有Internet Explorer窗口,internet-explorer,vbscript,admin,Internet Explorer,Vbscript,Admin,我需要一些关于在Windows7下使用InternetExplorer11的vbscript的帮助。我发现,当创建两个(或更多)IE对象时,当进入管理模式时,只有第一个对象可以在CreateObject(“Shell.Application”).Windows中看到 为了给出一个问题的例子,在下面的代码中,我运行了一个名为IE()的子对象,它只以通常的方式创建2个IE对象,并导航到bing和google。然后使用CreateObject(“Shell.Application”).windows上
CreateObject(“Shell.Application”).Windows中看到
为了给出一个问题的例子,在下面的代码中,我运行了一个名为IE()的子对象,它只以通常的方式创建2个IE对象,并导航到bing和google。然后使用CreateObject(“Shell.Application”).windows
上的循环列出这些窗口
第一次运行正常,两个窗口都被检测到,但当我在管理模式下重新启动脚本时,当调用同一个子系统时,只检测到第一个IE对象:
path = CreateObject("WScript.Shell").CurrentDirectory
If WScript.Arguments.length = 0 Then
' First try, running Sub IEOpen not as admin
IEOpen
'relaunch script as admin
Set ShellApp = CreateObject("Shell.Application")
ShellApp.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & " " & Chr(34) & _
" " & Chr(34) & path & Chr(34),"", "runas", 1
Else
Start
End If
Sub Start
'Run same Sub again but in admin mode
IEOpen
end sub
Sub IEOpen()
Set IE1 = WScript.CreateObject("InternetExplorer.Application")
Set IE2 = WScript.CreateObject("InternetExplorer.Application")
IE1.Navigate "www.bing.com"
IE2.Navigate "www.google.com"
IE1.Visible = true
IE2.Visible = true
msgbox CreateObject("Shell.Application").Windows.count
For Each win In CreateObject("Shell.Application").Windows
msgbox win.LocationURL
Next
IE1.Quit
IE2.Quit
End Sub
在我的完整代码中,我需要有两个不同的IE并以管理员的身份运行,所以我被卡住了,因为我无法访问第二个IE对象的属性。你知道我做错了什么,或者这个问题是否可以绕过