Showing posts with label Ping. Show all posts
Showing posts with label Ping. Show all posts

Tuesday, February 7, 2017

VBScript Execute Ping

Dim oShell, oExec, sLine
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("ping google.com")

'Reading the output of the shell command thread
Do While Not oExec.StdOut.AtEndOfStream
    sLine = oExec.StdOut.ReadLine
    WScript.StdOut.WriteLine "Output: " & sLine
    WScript.Sleep 10
Loop

'Waiting for the shell command thread to end
'In case the output ends before the command
Do While oExec.Status = 0
    WScript.Sleep 100
Loop