@echo off rem PingSubNet.cmd rem Sat 11/09/2013 rem Chieh Cheng rem http://www.CynosureX.com/ rem GNU General Public License (GPL) Version 2, June 1991 SetLocal EnableDelayedExpansion set scriptDir=%~d0%~p0 set scriptName=%~n0%~x0 call SetNumberOfArguments.bat %* if %NumberOfArguments% equ 1 ( set subnet=%~1 call :run "!subnet!" ) else ( call :usage ) goto :end :ping set ip=%~1 java SystemOutPrint "Pinging %ip% . . . " call SetVariableToOutput.bat "ping -n 1 -w 1000 %ip% | java eGrep -c timed" set result=%OutputVariable% if %result% equ 1 ( java SystemOutPrint "dead.\r" ) else ( echo alive^^! ) goto :EOF :run set subnet=%~1 set count=1 for /L %%n in (1, 1, 255) do ( call :ping "%subnet%.%%n" ) goto :EOF :usage echo Usage: "%scriptName%" subnet goto :EOF :end