0
我是VBScripting的新手。對不起,或者缺少必要的信息。我會盡我所能包括我能幫助你的一切。VBScript 80004005;按預期工作了幾個小時,突然不是
我的問題是,當我執行該腳本,我得到以下錯誤:
- Line: 22
- Char: 5
- Error: Unspecified error
- Code: 80004005
- Source: (null)
什麼奇怪的是,我一直在運行相同的腳本被多次整天沒有任何問題。現在,當我運行它時,顯示錯誤。腳本中沒有任何更改。我試過重新啓動,但那似乎什麼也沒做。
下面是代碼:
Call Main
Function Main
Dim IE
Dim pin
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
Set objShellApp = CreateObject("Shell.Application")
Set IE2 = WScript.CreateObject("InternetExplorer.Application", "IE_")
pin=inputbox("Pin: ","Enter the pin to continue","")
IE.Visible = True
IE.Navigate "https://ps.hasdk12.org/admin/pw.html"
For Each objWindow in objShellApp.Windows
If LCase(objWindow.LocationName) = LCase("PowerSchool") Then
Set IE2 = objWindow
End If
WScript.Sleep (5)
Next
With IE2.Document
.getElementByID("fieldPassword").value = "username;" + pin
.getElementByID("btnEnter").click
End With
For Each objWindow in objShellApp.Windows
If LCase(objWindow.LocationName) = LCase("Start Page") Then
Set IE2 = objWindow
End If
WScript.Sleep (5)
Next
End Function
原始代碼不會等待的原因是由於某種原因導航完成後實例丟失。你可以閱讀更多關於它[這裏](http://adminthoughtcollection.blogspot.com/2011/09/accessing-ie-from-vbscript.html)(看起來像它的Windows 7 +問題)IE2實例是因爲我是一個noob :) – 2014-09-05 12:11:45
現在很清楚,一旦我建議類似問題的解決方案,請參閱[部分UPD2在答案](http://stackoverflow.com/a/23232573/2165759)。 – omegastripes 2014-09-05 15:26:10