Microsoft

Create an IP address tracking batch tool in Windows XP Pro

Finding your network's free IP addresses in Windows XP Pro can work a little too well, giving you more entries than you can easily manage. Here's how to narrow your search for unused IP addresses and output the results to a short, easy-to-read text file.

When you're troubleshooting DHCP problems in Windows XP Pro and want to find out which addresses in a range of IP addresses aren't in use, you may open a command prompt window and launch a ping loop with the For…In…Do command. For example, to find out which IP addresses aren't being used in the range 192.168.1.1 to 192.168.1.100, you might use the command For /L %f in (1,1,100) Do Ping.exe -n 2 192.168.1.%f.

This command will report all the IP addresses, whether in use or not; you'll also have to scroll through a vast number of entries on the command line. You can avoid these inconveniences with a short batch file that returns only those IP addresses that aren't in use, and then compiles the results in a text file. Here's how:

  1. Launch Notepad and type the following commands:
    @Echo off
    date /t > IPList.txt
    time /t >> IPList.txt
    echo =========== >> IPList.txt
    For /L %%f in (1,1,100) Do Ping.exe -n 2 192.168.1.%%f | Find
    "Request timed out." && echo 192.168.1.%%f Timed Out >>
    IPList.txt && echo off
    cls
    Echo Finished!
    @Echo on
    Notepad.exe IPList.txt
  2. Save the file as IPTracker.bat and close Notepad.

Keep in mind that the entire For…In…Do command consists of several commands strung together with &&s. The command begins with the word For and ends with the word off, and the entire command must be on one line. Also, be sure to replace the example numbers with numbers from the IP addresses you wish to track.

Now when you troubleshoot a DHCP problem, you can locate and double-click the IPTracker.bat file in Windows Explorer, and then launch an IP address tracking tool batch that will find only those addresses that aren't in use and then display the results in Notepad. (In this case, the saved batch file becomes an IP address tracking tool that can be created once and used over and over.)

Note: This tip applies only to Windows XP Professional.

Miss a tip?

Check out the Windows XP archive, and catch up on our most recent Windows XP tips.

Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

Editor's Picks