windows 批处理脚本来ping指定的IP地址?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4912381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
batch script to ping specified ip addresses?
提问by mr_eclair
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.
我想在Windows下编写一个批处理脚本来ping指定范围的IP地址。就像我想 ping 192.168.0.1 到 192.168.0.10 并想检查他们的响应是否在 Windows 批处理脚本下到来。
回答by Dr. belisarius
@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 )
回答by Mikel
Well, the for
loop would look like this:
好吧,for
循环看起来像这样:
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
)