代號爲「mystifeid」一個神祕的人解決了這個難題,在這個網站上後第三下來: http://social.msdn.microsoft.com/Forums/uk-UA/scripting/thread/e3936dff-7395-4a6a-ab35-aa1aab0bcd71
這裏是他們可愛代碼:
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 & "Adapter Name : " & objItem2.Name & VbCrLf
resultString = resultString & "MAC Address : " & objItem2.MACAddress & VbCrLf
For Each objItem In colItems
If Mid(objItem.Name, 1, 5) = nicName Then
resultString = resultString & "CurrentBandwidth : " & objItem.CurrentBandwidth & VbCrLf
End If
Next
End If
Next
Set objLocator = Nothing
Set objWMI = Nothing
Set colItems = Nothing
Set colItems2 = Nothing
WScript.Echo resultString
PS-我會獸醫靠在Win7和Win2008很快就讓大家知道了。
第三篇文章在此鏈接中有適用於XP的VBScript:http://social.msdn.microsoft.com/Forums/uk-UA/scripting/thread/e3936dff-7395-4a6a-ab35-aa1aab0bcd71 – Lizz
@莉絲謝謝你!有用!現在,如果你可以發表你的評論作爲答案,我將它標記爲* * *答案儘快:) – pepoluan
很高興它幫助! :) – Lizz