Monday, 18 June 2012

How to ping Multiple pc's using batch file & generate log file


I am working as System admin ,every morning i comes to office i 


need to ping all servers to check they are alive or not & the list of 


server is huge so if i will ping to every server by typing I adress for


every server it will take more time & energy but finally i write a 


batch script which ping all the servers or host on the network & 


saves a log file & all this happens with a single click...


Ok let's start creating batch file.


Copy the code below




@ECHO 
:LOOPSTART
time /T >> Pinglog.txt
ping  192.168.0.1 -n 4 >> Pinglog.txt
ping  192.168.0.2 -n 4 >> Pinglog.txt
ping  192.168.0.3  -n 4 >> Pinglog.txt
ping  192.168.0.4  -n 4 >> Pinglog.txt
ping  192.168.0.5  -n 4 >> Pinglog.txt
ping  192.168.0.6  -n 4 >> Pinglog.txt
pause


Now paste it into notepad & save it as autoping.bat


now the fact is in your case the ip address  will change so you just 


replace the ip  address  with your IP address in the batch file, & 


you can add more ip adresses for ping there is no limit...


To Auto ping just double click the file & it will automatically 


generate pinglog.txt in your batch file's directory by opening 


pinglog.txt you can see the whole report....


That's It ,


Work Smarter...




13 comments :

  1. Hey it was useful... But my requirement it quite different... I have more than 500 hosts which i need to ping if any one down i should be alerted through an email it is possible... If so please let me know at raja.root@gmail.com

    ReplyDelete
  2. its very working thanks

    ReplyDelete
  3. Its simpler! Shahrukh instead of individual IP's can we give the range of IP and running this batch file ?

    ReplyDelete
  4. Its pretty simpler, friend can we give a set of IP range instead of manually giving each IP ?

    ReplyDelete
  5. good start.... thank for getting me started back to writing batch commands

    ReplyDelete
  6. Thanks for your post, it's helped me.

    ReplyDelete
  7. hi its me again..please i need a script batch file which can ping ip address on a server and returns notification about the ip addresses which are not pingable. i need it so badly you can please send it to me through matthewchurchill50@gmail.com... thank you

    ReplyDelete
  8. can we print print ping successful or unsuccessful. .

    ReplyDelete
  9. I wondered if there was anyway to specify a name in the log file for each IP address?

    ReplyDelete
  10. after the echo command I used
    del Pinglog.txt
    pause
    and set N to 2 instead of 4... less junk, you can also go by pc name, not IP for all those that don't know.

    ReplyDelete
  11. Works great, thanks for the little tip.

    ReplyDelete