- set gateway_ip=192.168.0.1
- set net_ip=www.baidu.com
- set /a count=0
- set file=log.txt
-
- :start
- :: 这里的写法有问题?
- set /a %count%=%count%+1
- echo '开始第%count%次ping' >> %file%
- (ping %gateway_ip% -n "1"|find /i "TTL">nul&&echo 网关连接正常。||echo 网关连接失败。) >> %file%
- (ping %net_ip% -n "1"|find /i "TTL">nul&&echo 外网连接正常。||echo 外网连接失败。) >> %file%
- TIMEOUT /T 5
- goto start
- pause
复制代码
:: 这里的写法有问题?
set /a %count%=%count%+1 |