@echo off set /a ip0 = "192" set /a ip1 = "168" set /a ip2 = "1" set /a ip3 = "1" :ping ping %ip0%.%ip1%.%ip2%.%ip3% -n 1 -w 10 | find "TTL" >>ip.txt set /a ip3 = %ip3% + "1" if %ip3% == 255 (set /a ip2 = "%ip2%" + "1") & (set /a ip3 = "1") if not %ip2% == 255 goto ping