Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for nicspeed.vbs

(view source code of nicspeed.vbs as plain text)

  1. On Error Resume Next
  2.  
  3. Select Case WScript.Arguments.UnNamed.Count
  4. 	Case 0
  5. 		Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
  6. 		Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , wbemFlagReturnImmediately + wbemFlagForwardOnly )
  7. 		For Each objItem in colItems
  8. 			strComputer = objItem.Name
  9. 		Next
  10. 	Case 1
  11. 		strComputer = WScript.Arguments.UnNamed(0)
  12. 	Case Else
  13. 		Syntax( )
  14. End Select
  15.  
  16. Const wbemFlagReturnImmediately = &h10
  17. Const wbemFlagForwardOnly = &h20
  18.  
  19. Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/WMI" )
  20. Set colItems      = objWMIService.ExecQuery( "SELECT * FROM MSNdis_EthernetCurrentAddress WHERE Active = True", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )
  21. For Each objItem In colItems
  22. 	strMsg = strMsg & "Ethernet Adapter : " & objItem.InstanceName      & vbCrLf
  23. 	Set col2Items = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed WHERE InstanceName = '" & objItem.InstanceName & "'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
  24. 	For Each obj2Item In col2Items
  25. 		strMsg = strMsg & "NDIS Link Speed  : " & obj2Item.NdisLinkSpeed & " kBps" & vbCrLf
  26. 	Next
  27. 	strMsg = strMsg & vbCrLf
  28. Next
  29. WScript.Echo strMsg
  30.  
  31.  
  32. Sub Syntax( )
  33. 	strMsg = strMsg & vbCrLf _
  34. 	       & "NICSpeed.vbs,  Version 1.00" & vbCrLf _
  35. 	       & "Display network adapter link speed for " _
  36. 	       & "any WMI enabled computer on the network" & vbCrLf & vbCrLf _
  37. 	       & "Usage:  CSCRIPT  //NOLOGO  NICSPEED.VBS  " _
  38. 	       & "[ computer_name ]" & vbCrLf & vbCrLf _
  39. 	       & "Where:  " & Chr(34) & "computer_name" & Chr(34) _
  40. 	       & " is the optional name of a remote computer" & vbCrLf _
  41. 	       & "                        (default is the local computer " _
  42. 	       & "name)" & vbCrLf & vbCrLf _
  43. 	       & "Written by Rob van der Woude" & vbCrLf _
  44. 	       & "http://www.robvanderwoude.com" & vbCrLf & vbCrLf _
  45. 	       & "Created with Microsoft's Scriptomatic tool" & vbCrLf _
  46. 	       & "http://www.microsoft.com/technet/treeview/default.asp" _
  47. 	       & "?url=/technet/scriptcenter/WMImatic.asp" & vbCrLf
  48. 	WScript.Echo strMsg
  49. 	WScript.Quit(1)
  50. End Sub
  51.  

page last uploaded: 2017-04-06, 13:33