Operations 6 min read

Efficient Batch‑Ping Techniques: Scan Hundreds of Devices with Simple CMD Scripts

This guide explains how to efficiently batch‑ping large numbers of IP addresses using simple Windows CMD loops, shows progressive script upgrades that log reachable and unreachable hosts to separate files, and provides a final method for scanning multiple subnets from an external list.

Open Source Linux
Open Source Linux
Open Source Linux
Efficient Batch‑Ping Techniques: Scan Hundreds of Devices with Simple CMD Scripts

Why Batch Ping Matters

Ping is the most common command for checking network connectivity; it helps identify timeouts and high latency, which are essential for troubleshooting.

Scenario: Many Devices

When you need to check dozens, hundreds, or thousands of devices, pinging each individually is impractical.

1. Basic Batch Ping of a Subnet

Use a simple FOR loop to ping every address in a /24 subnet. for /L %D in (1,1,255) do ping 10.168.1.%D Replace the IP range with the subnet you want to test.

2. Upgrade: Save Results to a File

Redirect the output to a text file and later search for “TTL=” to find reachable hosts.

for /L %D in (1,1,255) do ping -n 10.168.1.%D >> a.txt

Open a.txt and search for “TTL=”.

3. Upgrade: Separate Reachable and Unreachable Hosts

Direct successful and failed pings to different files.

for /l %D in (1,1,255) do (ping 192.168.1.%D -n 1 && echo 192.168.1.%D>>ok.txt || echo 192.168.1.%D>>no.txt)

4. Ultimate Method: Multiple Subnets from a List

Read IP addresses from an external ip.txt file and log results.

for /f %D in (ip.txt) do (ping %D -n 1 && echo %D>>ok.txt || echo %D>>no.txt)

Prepare ip.txt with the addresses you want to scan.

This set of scripts provides a practical way to automate network health checks across large environments; just adjust the IP ranges or input file as needed.

automationpingbatch scriptingIP scanningWindows cmd
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.