Skip to sidebar Skip to content
Ipercube Technical
Jack of all trades, master of none
Date: Time: - Stardate:
Welcome, Log in by clicking  Here!
SS64
MDN
Stack
Code
GitHub
Wiki
Convert
V Studio
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions
Ipercube Technical
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions

Exec Ping

Executes a ping request to a specified host using WMI and returns the response time(s) as a string.

This function uses WMI ( Win32_PingStatus ) to perform the ping and collect response time(s). If multiple responses are received, they are concatenated using / as a separator.

VB
    Public Function ExecPing(Host) As String

        If String.IsNullOrEmpty(Host) Then Return String.Empty

        Dim oPing As Object, oRetStatus As Object
        Dim szResult As String = String.Empty
        Dim bSuccess As Boolean
        bSuccess = False

        Try
            oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & Host & "'")

            For Each oRetStatus In oPing
                If String.IsNullOrEmpty(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
                    'sPing = "timeout" 'oRetStatus.StatusCode
                Else
                    If String.IsNullOrEmpty(szResult) Then
                        szResult = oRetStatus.ResponseTime
                    Else
                        szResult += "/" + oRetStatus.ResponseTime
                    End If
                    bSuccess = True
                End If
            Next

            If bSuccess Then
                Return szResult
            Else
                Return "Timeout"
            End If

        Catch ex As Exception
            Return "Not Found"
        End Try

    End Function
Posted by ipercube


© 2026 Ipercube Design