我需要在Windows 7下使用Internet Explorer 11对vbscript提供一些帮助 . 我发现在创建两个(或更多)IE对象时,在进入管理模式时,只有第一个看到 CreateObject("Shell.Application").Windows .

举一个问题的例子,在下面的代码中我运行一个名为IE()的子程序,它只按常规方式创建2个IE对象并导航到bing和google . 然后使用 CreateObject("Shell.Application").Windows 上的循环列出这些窗口 .

第一次运行正常,两个窗口都被检测到,但是当我在管理模式下重新启动脚本时,当调用相同的Sub时,只检测到第一个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对象的属性 . 你知道我做错了什么,或者是否可以绕过这个问题?