Windows Batch: Scan subnet with Ping and For loop

Quick tip for Windows users, ping a range of addresses using a For loop.

With an IP scanner it is easy to find devices on the network.

However, it is not always possible to install such software, e.g. on company computers. One, somewhat slower variant with batch file:

for /l %%i in (1,1,255) do ping -n 1 192.168.72.%%i

The ping command pings the range 192.168.72.1 to 192.168.72.255 with one ping at a time.

The values in brackets specify the parameters for the For loop, 1,1,255 means: from 1, in steps of 1 to 255.

Leave a Reply

Your email address will not be published. Required fields are marked *