lynx16 Posted January 11, 2012 Posted January 11, 2012 I got the same error initially however I noticed that if you name the vbs script something else other than "ping.vbs" then it will run without errors i.e. if you call it "ping1.vbs" your problem should be solved. Hope this helps
call2rb Posted April 23, 2012 Posted April 23, 2012 Can you help me understand this script a little bit more? mainly the part below.I understand online and offline but what does the last one mean Unknown host (no DNS entry?If InStr(temp, "Reply from") Then ofile.writeline item & ","&strip&","&"Online." ElseIf InStr(temp, "Request timed out.") Then ofile.writeline item &","&strip&","&"No response (Offline)." ELSEIf InStr(temp, "try again") Then ofile.writeline item & ","&strip&","&"Unknown host (no DNS entry)."It's funny you'd ask for this, as I posted it today in another thread This does exactly what you asked, but I don't think it provides the results you asked for specifically. Also, it creates a .csv file, but that can easily be opened in excel for easy viewing. You can obviously edit it for your needs.Anyway, here you go:Const ForReading = 1Set objFSO = CreateObject("Scripting.FileSystemObject")Set objShell = CreateObject("WScript.Shell")If not objFSO.FileExists("servers.txt") THENwscript.echo "Please create a file named 'servers.txt' with one PC name to be pinged per line,"&_vbcrlf&"with a hard return at the end of each line."wscript.quitend iftempobj="temp.txt"Set objTextFile = objFSO.OpenTextFile("servers.txt", ForReading)logfile="results.csv"Set ofile=objFSO.CreateTextFile(logfile,True)strText = objTextFile.ReadAllobjTextFile.Closewscript.echo "Ping batch starting, please be patient. This could take some time to"&_vbcrlf&"finish, depending on the number of hosts to check. You "_&"will be "&vbcrlf&"notified upon the completion of this script."ofile.WriteLine ","&"Ping Report -- Date: " & Now() & vbCrLfarrComputers = Split(strText, vbCrLF)for each item in arrcomputersobjShell.Run "cmd /c ping -n 1 -w 1000 " & item & " >temp.txt", 0, TrueSet tempfile = objFSO.OpenTextFile(tempobj,ForReading)Do Until tempfile.AtEndOfStream temp=tempfile.readall striploc = InStr(temp,"[") If striploc=0 Then strip="" Else strip=Mid(temp,striploc,16) strip=Replace(strip,"[","") strip=Replace(strip,"]","") strip=Replace(strip,"w"," ") strip=Replace(strip," ","") End If If InStr(temp, "Reply from") Then ofile.writeline item & ","&strip&","&"Online." ElseIf InStr(temp, "Request timed out.") Then ofile.writeline item &","&strip&","&"No response (Offline)." ELSEIf InStr(temp, "try again") Then ofile.writeline item & ","&strip&","&"Unknown host (no DNS entry)."End If LoopNexttempfile.closeobjfso.deletefile(tempobj)ofile.writeline ofile.writeline ","&"Ping batch complete "&now()wscript.echo "Ping batch completed. The results will now be displayed."objShell.Run("""C:\Program Files\Microsoft Office\OFFICE11\excel.exe """&logfile)Create a file named servers.txt in the same folder as this script, with one computername/ip address that you'd like to ping per line. That should be all you need
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now