- @echo off & title 网络高延迟报警Beta
- set t=15
- set ip=192.168.1.1
- set file=记录.txt
- set tee=^|cscript /nologo "%temp%\tee.vbs" ^>^>%file%
- echo 正在持续检测中...
- echo>"%temp%\tee.vbs" text = wscript.stdin.readall:wscript.echo text:wscript.stderr.write text
- :2
- for /f "tokens=3 delims==" %%a in ('ping %ip% -n 1') do (
- if not "%%a" GEQ "0" echo %date:~0,10% %time:~0,8% 网络异常%tee% & echo & goto 2
- for /f "delims=m" %%b in ("%%a") do (if %%b GEQ %t% echo %date:~0,10% %time:~0,8% 延迟过大:%%bms%tee% & echo )
- ping 127.1 -n 2 >nul
- goto 2
- )
- echo %date:~0,10% %time:~0,8% 网络中断%tee% & echo & goto 2
复制代码 以前写的,超过15秒,主板蜂鸣器就报警 |