[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
用批处理来监控迅雷的下载流量恐怕做不到...

TOP

  1. StrComputer = "."
  2. ConnectionID = "本地连接1"
  3. '这里根据实际情况修改
  4. Set ObjectWSH = CreateObject("Wscript.Shell")
  5. Set ObjectWMI = Getobject("winmgmts:\\" & StrComputer)
  6. Set NetCards = ObjectWMI.ExecQuery("Select * from Win32_NetworkAdapter WHERE NetConnectionID='" & ConnectionID & "'")
  7. If NetCards.count<>0 Then
  8. For Each NetCard In NetCards
  9. WScript.Echo "Name: " & NetCard.Name & " MACAddress: " & NetCard.MACAddress
  10. NetCardName = NetCard.Name
  11. Next
  12. Else
  13. Wscript.Echo "网卡不存在."
  14. WScript.Quit(0)
  15. End If
  16. '获取用于上网的网卡信息
  17. CurrentFlow
  18. BeginFlow = CurrentFlow
  19. '获取开始时接收的流量(字节)
  20. Wscript.Echo "BeginFlow: " & BeginFlow
  21. WScript.Sleep 18000
  22. '定义时间范围
  23. CurrentFlow
  24. EndFlow = CurrentFlow
  25. '获取结束时接收的流量(字节)
  26. Wscript.Echo "EndFlow: " & EndFlow
  27. Result = EndFlow-BeginFlow
  28. If Result<10240 Then
  29. '10240即10KB,当18000秒(上面的时间范围)内接收流量小于10KB就关闭系统
  30. WScript.Echo "关闭系统."
  31. ObjectWSH.Run"shutdown.exe -s -t 0", 0, TRUE
  32. End If
  33. '计算结果并比较
  34. WScript.Echo "Exit..."
  35. WScript.Sleep 10000
  36. Function CurrentFlow
  37. Set ObjectFlows = ObjectWMI.InstancesOf("Win32_PerfRawData_Tcpip_NetworkInterface")
  38. For Each ObjectFlow In ObjectFlows
  39. If ObjectFlow.Name=NetCardName Then
  40. CurrentFlow = ObjectFlow.BytesReceivedPersec
  41. End If
  42. Next
  43. End Function
复制代码

TOP

返回列表