См. Это ==> Цикл функции?
Вы можете сделать это легко с помощью этого кода:
Option Explicit
Dim MyLoop,strComputer,objPing,objStatus
MyLoop = True
While MyLoop = True
strComputer = "smtp.gmail.com"
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery _
("select * from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then
MyLoop = False
Call MyProgram()
wscript.quit
End If
Next
Pause(10) 'To sleep for 10 secondes
Wend
'**********************************************************************************************
Sub Pause(NSeconds)
Wscript.Sleep(NSeconds*1000)
End Sub
'**********************************************************************************************
Sub MyProgram()
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
With WScript.CreateObject ("InternetExplorer.Application")
.Navigate "http://www.example.com/slideshow"
.fullscreen = 1
.Visible = 1
WScript.Sleep 10000
End With
On Error Goto 0
End Sub
'**********************************************************************************************
РЕДАКТИРОВАТЬ:
Wscript.echo(CheckConnection("https://www.google.com"))
'----------------------------------------------------
Function CheckConnection(URL)
On Error Resume Next 'swallow errors
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET",URL, False
o.send
If Err.Number <> 0 Then
CheckConnection = "An error occured. Data not retrieved."
'or whatever else you want to do in such a case.
Else
CheckConnection = "You are connected"
End If
On Error Goto 0 'back to normal error behaviour
End Function
'----------------------------------------------------