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 their 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
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.