I'm writing a script which, among other things, has to check for internet connectivity.
My idea is to create an IE object, browse to a website (a high visibility and high reliability one such as and test to see if that has worked by fetching the current browser object's window title (I was hoping to check for a returned error number or an event in the local event log but couldn't find either).
If it hasn't worked then I'd expect the window title to include the text "cannot display the web page".
I can't see how to get that title though. I've tried this to get what I'm after
but that just returns blanks.
Here's my function code:
All suggestions (on how to get what I'm after or alternative approaches) gratefully received.
JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
My idea is to create an IE object, browse to a website (a high visibility and high reliability one such as and test to see if that has worked by fetching the current browser object's window title (I was hoping to check for a returned error number or an event in the local event log but couldn't find either).
If it hasn't worked then I'd expect the window title to include the text "cannot display the web page".
I can't see how to get that title though. I've tried this to get what I'm after
Code:
MsgBox objIE.LocationName & vbCrLf & objIE.LocationURL
Here's my function code:
Code:
'-----------------------------------------
Sub CheckInternet()
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 = true
objIE.ToolBar = 0
objIE.statusbar=false
objIE.Left = 0
objIE.Top = 0
objIE.Width = 1024
objIE.Height = 768
objIE.Navigate "[URL unfurl="true"]http://www.microsoftbubububububububububbubuubuu.com"[/URL]
wscript.echo "Err.Number = '" & Err.Number & "'"
MsgBox objIE.LocationName &_
vbCrLf & objIE.LocationURL
do while not bQuit
wscript.sleep 500
loop
End Sub
'-----------------------------------------
Sub objIE_OnQuit
'wscript.echo "objIE_quit has been called"
bQuit=true
End Sub
All suggestions (on how to get what I'm after or alternative approaches) gratefully received.
JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]