本帖最后由 lynfr8 于 2010-3-21 23:53 编辑 While 1
$s1=0
$s2=0
$strComputer = "."
$wbemServices = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
$wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface")
For $wbemObject In $wbemObjectSet
$s1=$s1+$wbemObject.BytesReceivedPerSec
Next
sleep(1000)
$strComputer = "."
$wbemServices = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
$wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface")
For $wbemObject In $wbemObjectSet
$s2=$s2+$wbemObject.BytesReceivedPerSec
Next
$dd=$s2-$s1
MsgBox(1,"提示","每秒流量:"&$dd,10)
sleep(10)
WEnd
也许这段代码能帮助楼主
开一进程每一秒统计流量
再结合流量单位转换一下
当流量总和达到楼主初设定的值就触发既定事件(例如关机)
对这方面不熟悉只能这样给个简单答案了
请参考:
网络流量单位bps与系统单位byte转换 |