Hi, the code will do a ping test list of servers kept in the servers.txt file on C: drive. see the result in C:\PingResult.txt file. Please keep only one server name in a line ( in the server.txt file)
- Code: Select all
'Windows script for doing a ping test of list of servers
'Script by - Subash & Praveen Kumar
Dim strTarget, strPingResults
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\server.txt", 1)
sReportName = "C:\PingResult.txt"
Set fReport = objFSO.CreateTextFile(sReportName, True)
fReport.WriteLine "Server Name" & "," & "Ping status"
Do until objFile.AtEndofStream
Line=objFile.ReadLine
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec("ping " & Line)
strPingResults = LCase(WshExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
fReport.WriteLine Line & "," & " responded to ping."
Else
fReport.WriteLine Line & "," & " did not respond to ping."
End If
Loop