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”
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
