Friday, April 6, 2012

Ping Multiple Destination With Batch File

       A common tool that network and system admins make use of is the “Ping” command which is a very simple and effective way to verify a machine is available on the network (firewall rules depending of course). So if you find yourself having to ping multiple machines at once, a very useful tool is the batch files, which will not only ping all the ip addresses but also give you ping results in text file format with just single click.


      A batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually COMMAND.COM  or cmd.exe) reads the file and executes its commands, normally line-by-line. Batch files are useful for running a sequence of executables automatically and are often used by system administrators to automate tedious processes.
Steps to create batch file::
  1. Open up Notepad, type in the following commands (Example)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    @Echo off

    ping 192.168.1.1 > "%userprofile%\desktop\pingresult.txt"

    ping www.google.com >> "%userprofile%\desktop\pingresult.txt"

    ping 146.23.4.45 >> "%userprofile%\desktop\pingresult.txt"

    tracert 192.168.1.1 >> "%userprofile%\desktop\pingresult.txt"
    tracert www.google.com >> "%userprofile%\desktop\pingresult.txt"

    tracert 146.23.4.45 >> "%userprofile%\desktop\pingresult.txt"

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Remember::  > will run the command and create a file with ping results and >> will append or add next ip address ping results to the created file . So whenever you create batch file first command should always have single > and subsequent  commands should have  >>.
  2. Now save this file with Filename Ping_result.cmd or whatever you want and Change  Save as type to All files.
  3. Run the Ping_result.cmd and you will get pingresult.txt on your desktop.
       Play around with netstat , ipconfig and other commands by creating batch files in the similar manner.., just change the ping command to the command of your choice in the above example.

0 comments:

Post a Comment