- @echo off
- rem 保存为ansi编码
- setlocal enabledelayedexpansion
- for /l %%l in () do (
- set k=
- for /f "delims==" %%a in ('2^>nul set _') do (
- set %%a=
- )
- for /f "delims=" %%a in ('ping -n 1 192.168.1.1 2^>^&1 ^| findstr /rv "正在 统计信息"') do (
- set /a k+=101
- set _!k:~-2!=%%a
- )
- (for /f "delims=" %%b in ('set _ ^| find /i "ttl="') do (
- set str=%%b
- for /f "delims=m=" %%c in ("!str:*时间=!") do (
- if %%c lss 500 (
- set /a n+=1,m=l=0
- echo 连接服务器测试 %%c ms (^< 500ms) 第!n!次
- if !n! equ 10 (
- start "" "d:\1.exe"
- pause
- exit
- )
- ) else (
- set /a m+=1,n=l=0
- echo 连接服务器测试 %%b ms (^> 500ms) 第!m!次
- )
- )
- )) || (
- set /a l+=1,m=n=0
- echo 连接服务器测试 超时 第!l!次
- for /f "tokens=1* delims==" %%a in ('set _') do (
- echo errorinfo : [%%b]
- )
- )
- timeout 1 >nul
- echo=
- )
复制代码
|