How to ping a network using VBScript

You can ping a network using VBScript. Yes, you read it right. We don’t know how many times we must have the necessity to ping a given network but, in order to do that, you have to open a command prompt and do that.

VBScript works so well with the windows system that you can do almost anything. The only limitation is your knowledge. Here we will see how to ping a network using VBScript.

Example code to ping a network using vbscript
Function Ping_Network(sHost)
    
'This function checks that you can get through to the host you require
'Example usage:
' 'Check we have internet...
' If Not Ping_Network("www.google.com") Then
' Msgbox "Not connected to Internet",vbCritical,"Fatal Error:"
' Call ExitTest()
' End If
    
    msgbox "Gen_Ping : " & sHost
    
    Dim oPing, oRetStatus
    
    Set oPing = GetObject("winmgmts:").ExecQuery ("select * from Win32_PingStatus where address = '" & sHost & "'")
    
    For Each oRetStatus In oPing
        
        If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
            
            msgbox "Gen_Ping Failed - Status code :" & oRetStatus.StatusCode
            
            Ping_Network= False
            
        Else
            
            msgbox "Gen_Ping OK - Bytes : " & vbTab & oRetStatus.BufferSize
            msgbox "Gen_Ping OK - Time(ms) : " & vbTab & oRetStatus.ResponseTime
            msgbox "Gen_Ping OK - TTL(s) : " & vbTab & oRetStatus.ResponseTimeToLive
            
            Ping_Network= True
            
        End If
        
    Next
    
    Set oPing = Nothing
    
End Function

You may also read
jenkins

How to integrate Selenium with Jenkins – Step-by-step Example

FacebookTweetPinShares0Email Given the popularity of cloud technology, knowing How to integrate Selenium with Jenkins pipeline has become very important. Jenkins is the most famous tool for CI-CD. With the rapidly evolving software development industry, testing is also adopting the “Shift Left”…

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *