【问题标题】:Get network speed Windows 2003 cmd (Batch)获取网络速度 Windows 2003 cmd (Batch)
【发布时间】:2016-05-26 07:48:00
【问题描述】:

我正在尝试获取 Windows Server 2003 中的网络速度(网络适配器速度)。 我试图通过命令获得速度:

wmic nic where "MacAddress is not null" get Name, Speed

但结果只包含适配器的名称,速度列为空。

还有其他方法可以找到吗?

谢谢!

【问题讨论】:

  • 网卡是否已连接?报告的Speed 是各个连接的速度,而不是适配器本身支持的最大速度。

标签: windows batch-file networking cmd windows-server-2003


【解决方案1】:

答案是使用 vbs 脚本。

Dim strQuery, strQuery2, objLocator, objWMI, objItem, objItem2, colItems, colItems2, resultString, nicName
strQuery = "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface"
strQuery2 = "SELECT * FROM Win32_NetworkAdapter"
Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
Set objWMI = objLocator.ConnectServer( ".", "root\CIMV2" )
objWMI.Security_.ImpersonationLevel = 3
Set colItems2 = objWMI.ExecQuery( strQuery2, "WQL", 0 )
Set colItems = objWMI.ExecQuery( strQuery, "WQL", 0 )
resultString = ""
For Each objItem2 In colItems2
 If objItem2.NetConnectionStatus = 2 Then
  nicName = Mid(objItem2.Name, 1, 5)
  resultString = resultString & objItem2.Name

  For Each objItem In colItems
   If Mid(objItem.Name, 1, 5) = nicName Then
    resultString = resultString & " " & objItem.CurrentBandwidth & VbCrLf
   End If
  Next
 End If
Next
Set objLocator = Nothing
Set objWMI = Nothing
Set colItems = Nothing
Set colItems2 = Nothing

WScript.Echo resultString

谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-24
    相关资源
    最近更新 更多