This vbscript pings machines from a text file:

change the two variables for your input and output txt files:
strPATHout = “C:pingstatus.txt”
strPATHin = “C:pinglist.txt”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
ON ERROR Resume Next
 
'Define log paths (disable in portions if not using a reference file)
strPATHout = "C:#activepingstatus.txt"
strPATHin = "C:#activepinglist.txt"
 
'Define additional variables here
sMsgboxtxt = "ping?" 'message box text here
sMsgboxttl = "ping?" 'message box title here
sLogTitle = "ping?" 'log file title string
 
'Standard message stating whether you want to do this or not
intReturn = Msgbox(sMsgboxtxt, vbYesNo, sMsgboxttl)
    If intReturn = vbNo Then
        Wscript.echo "Quitting"
        WScript.quit
    End If
 
'Create filesystem objects (comment out OBJin if not using reference file)
Set OBJfs = CreateObject("Scripting.FileSystemObject")
Set OBJin = OBJfs.OpenTextFile(strPATHin)
Set OBJout = OBJfs.CreateTextFile(strPATHout,True)
 
OBJout.WriteLine(sLogTitle & " - " & Now)
 
Do Until OBJin.AtEndOfStream
   strComputer = lcase(OBJin.Readline)
 
pingstatus = Ping(strComputer)
OBJout.WriteLine(strComputer & "," & pingstatus)
wscript.echo strComputer & "," & pingstatus
 
Loop
 
function Ping(sComputer)
    dim objShell, objPing, strPingOut, flag
    set objShell = CreateObject("Wscript.Shell")  
    set objPing = objShell.Exec("ping -n 3 -w 1000 "& sComputer)
    strPingOut = objPing.StdOut.ReadAll
    if instr(LCase(strPingOut), "reply") then
        flag = TRUE
 if instr(LCase(strPingOut), "destination host unreachable") then
 flag = FALSE
 end if
        else
            flag = FALSE
        end if
        Ping = flag
end function
'close the file
OBJout.Close()
OBJin.Close()
Wscript.echo "Quitting"
 
' Quit the Script ----------------------------------------------------
WScript.quit