【发布时间】:2015-04-19 16:27:37
【问题描述】:
如果主机可访问,我如何签入批处理文件?问题是 ping 不仅在成功时返回 0,而且在 Destination host unreachable 错误时返回 0:
C:\>ping 192.168.1.1 -n 1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=3ms TTL=64
Ping statistics for 192.168.1.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 3ms, Average = 3ms
C:\>echo %errorlevel%
0
C:\>ping 192.168.1.105 -n 1
Pinging 192.168.1.105 with 32 bytes of data:
Reply from 192.168.1.102: Destination host unreachable.
Ping statistics for 192.168.1.105:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
C:\>echo %errorlevel%
0
有什么方法可以使用ping 或任何其他内置 Windows 工具来实现吗?如果可能的话,我宁愿不安装任何东西......
【问题讨论】:
标签: windows batch-file cmd network-programming ping