JediChris816

Ping Logging w/ Time Stamp

Apr 23rd, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. ***The Ping Log.bat file will need to be edited to suit your host IP and pinging address IP. Right-click on the Ping Log.bat and select edit. I recommend using Notepad++. If you don't have Notepadd++, you can download it from here: http://notepad-plus-plus.org/download/v6.5.5.html.
  2.  
  3. You will also need to create a blank .txt document and save as, i.e., ping_log.txt or pinglogging.txt, whatever you wish to use. You will also need to set the path to this log file in the Ping Log.bat.***
  4.  
  5. Save this code below as PingLog.bat
  6.  
  7. Copy this code:
  8.  
  9. @echo off
  10. setlocal enabledelayedexpansion
  11. set hostIP=xxx.xxx.xxx.xxx
  12. :loop
  13. set pingline=1
  14. for /f "delims=" %%A in ('ping -n 1 -w 250 -l xxx.xxx.xxx.xxx') do (
  15. if !pingline! equ 2 (
  16. set logline=!date! !time! "%%A"
  17. echo !logline! | find "TTL=">nul || (
  18. set logline=!logline:"=!
  19. echo !logline! >> C:\Users\xxx.xxx.xxx.xxx\Desktop\pinglog.txt
  20. )
  21. )
  22. set /a pingline+=1
  23. )
  24. goto loop
  25.  
  26. ***The first xxx.xxx.xxx.xxx in the code is the host IP address, your IP address. The 2nd xxx.xxx.xxx.xxx in the code (line 6) is the IP address you are going to ping. In line 11, where you see C:\Users\etc...this is the network path to the logile.
  27.  
  28. Now that you have the batch file, setup a text file for the batch file to write to.
Advertisement
Add Comment
Please, Sign In to add comment