Your technology certification is waiting. Enroll in Cloud Class ®
Set oWS = CreateObject("WScript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")
Set inFile = oFS.OpenTextFile("C:\IPlist.txt")
Set outFile = oFS.CreateTextFile("C:\names.csv")
Do While Not inFile.AtEndOfStream
write = ""
IP = inFile.ReadLine
cmd = "ping -a " & IP
Set ExecOutput = oWS.Exec(cmd)
Set Output = ExecOutput.StdOut
While Not Output.AtEndOfStream
data = Output.ReadLine
If Left(data,7) = "Pinging" Then
name = Split(data," ")
write = IP & "," & name(1) & ","
If InStr(data,"Packets:") Then
write = write & Left(Right(data,Len(data)-4),Len(Right(data,Len(data)-4))-2)
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.