PingResponsefromSubnet.bat

Modified on: Mon, May 1 2023 10:15 AM

This is a .bat file that will ping a /24 subnet and return any IP address that respond to a ping. 



@echo off
setlocal enabledelayedexpansion

set "subnet=192.168.1"
set "outputfile=C:\path\to\your\folder\responsive_ips.txt"

echo Checking IP addresses in subnet %subnet%.0/24...
echo Responsive IPs: > %outputfile%

for /l %%i in (1,1,254) do (
  set "ip=%subnet%.%%i"
  echo Pinging !ip!...
  ping -n 1 -w 1000 !ip! | find "TTL=" > nul && (
    echo !ip! >> %outputfile%
    echo !ip! is responsive.
  ) || (
    echo !ip! is not responsive.
  )
)

echo Scan complete. Responsive IPs saved to %outputfile%.
Generic


Was this answer helpful?