我在网上找到一段关于流量监控的批处理,可是运行后计数全为0,不知这个批处理哪有问题,请帮忙看看。我的系统是WIN8.1。- @echo off & setlocal ENABLEDELAYEDEXPANSION
- MODE con: COLS=22 LINES=10
-
- for /f "tokens=2,3" %%i in ('netstat -e ^|findstr "Bytes"') do (
- set oldrec=%%i
- set oldsent=%%j
- )
-
- :loop
-
- echo WScript.Sleep 1000 > %temp%\tmp$.vbs
- cscript //nologo %temp%\tmp$.vbs
-
- for /f "tokens=2,3" %%i in ('netstat -e ^|findstr "Bytes"') do (
- set newrec=%%i
- set newsent=%%j
- )
-
- set /a rec=(%newrec%-%oldrec%)*8/1024
- set /a sent=(%newsent%-%oldsent%)*8/1024
-
- cls
- echo 下载流量:%rec% kbits
- echo.
- echo 上传流量:%sent% kbits
- set /a oldrec=newrec
- set /a oldsent=newsent
- goto :loop
复制代码
|