01 @echo off
@echo 该程序用于监控局域网内的网络流量状况!
@echo 主要通过对ping的返回结果进行分析判断:
@echo 1.选取的测试服务器为www.baidu.com
@echo 2.测试发送包大小为默认的32bytes
@echo 3.一次测试对5次ping的结果进行判断
@echo .....................................................
set /p MAX=请自定义可接受的最大延迟数(ms):
set /p TIMEOUTMAX=请自定义可接受的最大掉包次数(小于5):
goto FLUX
:FLUX ::定义模块,用于计算出当前电脑5次ping结果后的最小值与掉包次数。
ping -n 5 www.baidu.com >ping.txt
find "Minimum" ping.txt >pingmin.txt
find "Lost" ping.txt >pingtimeout.txt
for /f "skip=2 tokens=3" %%M in (pingmin.txt) do set PING=%%M
echo %PING% >pingminnum.txt
for /f "tokens=1 delims=m" %%I in (pingminnum.txt) do set NUM=%%I
for /f "skip=2 tokens=10" %%J in (pingtimeout.txt) do set TIMEOUT=%%J
echo %PING% Lost %TIMEOUT%/5
if %TIMEOUT% GEQ %TIMEOUTMAX% (goto WARNING)
if %NUM% GEQ %MAX% (goto WARNING) else goto CONTINUE
:WARNING
mshta vbscript:msgbox("网速已经慢于预设值!请立刻检查是否有ARP病毒或有人在下载!",64,"警告窗口")(window.close)
goto CONTINUE
:CONTINUE
goto FLUX ::从这里开始再次回到FLUX模块进行循环