Try this:
::@ECHO OFF
REM This script pings all IPAdresses on an Xfinity Router.
::v1.0 - BTE - 24FEB19
::
FOR /L %%i in (1,1,254) DO ping -n 1 10.0.0.%%i | findstr "ms" && (echo 10.0.0.%%i)>>"pingable_ips.txt"
for variable in batch file should use %%. (On cmd prompt use single %)
- The loop content needs to be inside a pair of parentheses, or in the same line of
for.
- You need
in after the for variable.
- And when you are testing, don't use
@echo off yet.
Here I used the ms in the reply message as the signal, you can change it according to your situation.
You can put loop inside a pair of parentheses too:
FOR /L %%i in (1,1,254) do (
ping -w 77 -n 1 10.0.0.%%i | findstr "ms" && (echo 10.0.0.%%i)>>"pingable_ips.txt"
)
pause
So you can add other things inside the loop (inside the parens).
Added the -w timeout switch, to speed it up, for local ips are quick, you can increase the time.
Check for /?, ping /?, and findstr /? for more.