Hello.
I have a script (which some of you may remember part of the development of) which does a fairly basic test to see if our internet connectivity is up.
Most of the time when I run it it works just fine, but sometimes I get the following error:
[tt]Checks.vbs(650, 5) Microsoft VBScript runtime error: Object required: 'objIE.Document.Body'[/tt]
Line 650 is this line from the main code body below:
Here's the main code snippet:
So the question is, why does the error happen sometimes (I'd estimate it at between about 1 time in 20-30 runtimes)? Or, is there a way to mitigate against it (I thought the [tt]Do While objIE.Busy = True[/tt] loop was for that...)?
JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
I have a script (which some of you may remember part of the development of) which does a fairly basic test to see if our internet connectivity is up.
Most of the time when I run it it works just fine, but sometimes I get the following error:
[tt]Checks.vbs(650, 5) Microsoft VBScript runtime error: Object required: 'objIE.Document.Body'[/tt]
Line 650 is this line from the main code body below:
Code:
If InStr(objIE.Document.Body.innerHTML, "Internet Explorer cannot display the webpage") > 0 Then
Code:
Sub CheckInternet(strTestURL)
Set objIE = wscript.CreateObject("InternetExplorer.Application","objIE_")
If Err.Number <> 0 Then
On Error GoTo 0
Msg = "IE application not found."
MsgBox Msg,vbExclamation,strAppDescription
Wscript.Quit
End If
On Error GoTo 0
objIE.visible = false 'true
objIE.ToolBar = 0
objIE.statusbar=false
objIE.Left = 0
objIE.Top = 0
objIE.Width = 1024
objIE.Height = 768
objIE.Navigate strTestURL
Do While objIE.Busy = True
WScript.Sleep 500
Loop
WScript.Sleep 500
If InStr(objIE.Document.Body.innerHTML, "Internet Explorer cannot display the webpage") > 0 Then
strTempErrorMsg = " Unable to connect to " & strTestURL & ". Trying "
strInternetErrorText = strInternetErrorText & strHTMLTab & strHTMLTab & "Unable to connect to " & strTestURL & ".<br>"' & ". Trying " &
strInternetError=True
Else
strInternetError=False
wscript.echo " Tested internet connectivity to " & strTestURL & " OK."
strReport = strReport &_
strHTMLTab & "OK<br>"
End If
objIE.quit
JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]