Batch Script - Ping Address - Write to file if failure

天大地大妈咪最大 提交于 2019-12-04 18:01:14

In ipv4, ping command only raises errorlevel if there are packets lost. But in you are pinging a machine in your same subnet, you get no packets lost.

The easier way to test for ping success is to test for the "TTL=" string in the output of the ping

ping -n 1 %ipaddress% | find "TTL=" > nul
if errorlevel 1 echo %date% %time% >> failurelog.txt
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!