I want to write a batch script under Windows to ping a specified range of IP addresses. Like I want to ping 192.168.0.1 to 192.168.0.10 and want to check if th开发者_开发技巧eir response is coming or not under Windows batch script.
@echo off
for /L %%i in (1,1,10) do (
@echo testing 192.168.0.%%i
ping 192.168.1.%%i > nul
if ERRORLEVEL 1 @echo error ping %%i )
Well, the for
loop would look like this:
for /l %i in (1,1,10) do ping 192.168.0.%i
So the script would be something like:
for /l %i in (1,1,10) do (
ping 192.168.0.%i
if %errorlevel% neq 0 echo error
)
精彩评论