heres a batch i wrote a lil while ago, will ping 10.1.1.1-254 and output the ip's that are successful, you should be able to modify this to what you want
@echo off
set a=1
:start
ping -n 1 -r 4 -a 10.1.1.%a%
echo %errorlevel%
if %errorlevel% ==0 (ping -n 1 -r 4 -a 10.1.1.%a% >> a.txt) else (echo error 10.1.1.%a%)
echo ------------ >> a.txt
set /a a+=1
if %a% == 255 goto end
goto start
:end
pause
exit