I need a VBScript to find the speed and duplex setting on all installed Network Interface Cards on a Windows Server 2008

I need a VBScript to find the speed and duplex setting on all installed Network Interface Cards on a Windows Server 2008
matthew phungAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The speed and duplex settings are in the Windows registry but the exact location of all parameters is driver dependent.
As most drivers use the same structure you could try to use the following VBScript I created.
Please execute the script with "cscript.exe"

'* Get Speed/Duplex settings
'* Version 1.00
'* Zalazar
Const HKEY_LOCAL_MACHINE = &H80000002

Dim fso, WshNetwork, WshShell, objReg

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

' --------  MAIN  --------
call GetSpeedDuplex()

Wscript.Quit 0

' --------  SUBS  --------
Sub GetSpeedDuplex()
  On Error Resume Next
  Dim strKeyName
  Dim aSubkeys, sSubkey, strKeyPath
  Dim sComponentId, sSpeedDuplexSetting, sDriverDesc, sSpeedDuplexDesc

  Wscript.echo "Reading NIC settings"
  strKeyName = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"
  objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyName, aSubkeys
  If IsArray(aSubkeys) = False Then Exit Sub

  For Each sSubkey In aSubkeys
    sComponentId = ""
    sSpeedDuplexSetting = ""
    sDriverDesc = ""
    sSpeedDuplexDesc = ""

    strKeyPath = strKeyName & "\" & sSubkey
    sComponentId = WshShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\ComponentId")
    If LCase(Left(sComponentId, 4)) = "pci\" Then
      sSpeedDuplexSetting = WshShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\*SpeedDuplex")
      sDriverDesc = WshShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\DriverDesc")
      sSpeedDuplexDesc = WshShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\Ndi\Params\*SpeedDuplex\enum\" & sSpeedDuplexSetting)
      Wscript.echo sDriverDesc & "|" & sSpeedDuplexDesc & "|" & sSpeedDuplexSetting
    End If
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
matthew phungAuthor Commented:
Thank you for sharing this script.  It is very helpful. I will compile a list of settings based on the brand and model of the cards. I will share the list when I am done with it. Anyone who would like to contribute to the list of driver settings may post it here and I will include it in my complied list.
You're welcome. Thanks in advance for creating the list and sharing it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.