获取网络速度Windows 2003 cmd(批处理)

时间:2016-02-15 11:53:53

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

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

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

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

有没有其他方法可以找到它?

谢谢!

1 个答案:

答案 0 :(得分:0)

答案是使用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

谢谢!