ping status true or false





0
Date Submitted Thu. Mar. 2nd, 2006 10:11 AM
Revision 1 of 1
Syntax Master dannyboy
Tags Ping | VBSCRIPT
Comments 0 comments
check if host is pingable or not

Function ConvertPing(HostName)

        Const ForReading = 1, ForWriting = 2, ForAppending = 8
        Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
        DIM fso, f, ts

        Set fso = CreateObject("Scripting.FileSystemObject")
        Set f = fso.GetFile("ping.txt")
        Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)

        Do While ts.AtEndOfStream <> TRUE
                retstring = ts.ReadLine
                P = InStr(retstring, "Pinging")
                If P > 0 Then
                        P1 = InStr(retstring," [")
                        If P1 > 0 Then
                                HostName = Mid(retstring,9,P1-9)
                        End If
                End If
                If InStr(retstring, "Reply")> 0 Then
                        ConvertPing = TRUE
                        Exit Do
                End If
        Loop
       
        ts.Close

End Function
 

Comments

There are currently no comments for this snippet.

Voting