Link to home
Create AccountLog in
Avatar of davidsummers
davidsummers

asked on

Remotley Query Client PC Network Duplex settings

Is there a way with either WMI, 3rd party utilities or standard windows commands to remotley enumerate the current state of a Network card's link speed and Duplex settings

We will be roling out new Network infrastructure. I need to make sure that all Client NICS are set to autonegiate. However I know for a fact, that some clients are set to 10mbs 1/2 Duplex. I need to remotley identify these clients so that I can then change the settings if required.

Logging on locally is not an option, as we are lookeing at over 100 machines spread out over 18 offices.

I know where the registry location is for the setting, but it is unigue for every network adapter

Key Name Value
HKLM\System\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001\Ndi\Params\DuplexMode\enum\1 Auto Negotiation
HKLM\System\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001\Ndi\Params\DuplexMode\enum\2 10Mbps/Half Duplex



I have had a look at the following 2 scripts from the MS script center, bet neither of them enumerate the link status of the NIC.


****************************Script 1************************************************

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
For Each objItem in colItems
    Wscript.Echo "Adapter Type: " & objItem.AdapterType
 
    Select Case objItem.AdapterTypeID
        Case 0 strAdapterType = "Ethernet 802.3"
        Case 1 strAdapterType = "Token Ring 802.5"
        Case 2 strAdapterType = "Fiber Distributed Data Interface (FDDI)"
        Case 3 strAdapterType = "Wide Area Network (WAN)"
        Case 4 strAdapterType = "LocalTalk"
        Case 5 strAdapterType = "Ethernet using DIX header format"
        Case 6 strAdapterType = "ARCNET"
        Case 7 strAdapterType = "ARCNET (878.2)"
        Case 8 strAdapterType = "ATM"
        Case 9 strAdapterType = "Wireless"
        Case 10 strAdapterType = "Infrared Wireless"
        Case 11 strAdapterType = "Bpc"
        Case 12 strAdapterType = "CoWan"
        Case 13 strAdapterType = "1394"
    End Select
 
    Wscript.Echo "Adapter Type Id: " & strAdapterType
    Wscript.Echo "AutoSense: " & objItem.AutoSense
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Index: " & objItem.Index
    Wscript.Echo "MAC Address: " & objItem.MACAddress
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Maximum Number Controlled: " & objItem.MaxNumberControlled
    Wscript.Echo "Maximum Speed: " & objItem.MaxSpeed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Net Connection ID: " & objItem.NetConnectionID
    Wscript.Echo "Net Connection Status: " & objItem.NetConnectionStatus
    For Each strNetworkAddress in objItem.NetworkAddresses
        Wscript.Echo "NetworkAddress: " & strNetworkAddress
    Next
    Wscript.Echo "Permanent Address: " & objItem.PermanentAddress
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Product Name: " & objItem.ProductName
    Wscript.Echo "Service Name: " & objItem.ServiceName
    Wscript.Echo "Speed: " & objItem.Speed
Next



****************************Script 2************************************************

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")
For Each objItem in colItems
    Wscript.Echo "ARP Always Source Route: " & objItem.ArpAlwaysSourceRoute
    Wscript.Echo "ARP Use EtherSNAP: " & objItem.ArpUseEtherSNAP
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Database Path: " & objItem.DatabasePath
    Wscript.Echo "Dead GW Detection Enabled: " & objItem.DeadGWDetectEnabled
    Wscript.Echo "Default IP Gateway: " & objItem.DefaultIPGateway
    Wscript.Echo "Default TOS: " & objItem.DefaultTOS
    Wscript.Echo "Default TTL: " & objItem.DefaultTTL
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DHCP Enabled: " & objItem.DHCPEnabled
    Wscript.Echo "DHCP Lease Expires: " & objItem.DHCPLeaseExpires
    Wscript.Echo "DHCP Lease Obtained: " & objItem.DHCPLeaseObtained
    Wscript.Echo "DHCP Server: " & objItem.DHCPServer
    Wscript.Echo "DNS Domain: " & objItem.DNSDomain
    Wscript.Echo "DNS Domain Suffix Search Order: " & _
        objItem.DNSDomainSuffixSearchOrder
    Wscript.Echo "DNS Enabled For WINS Resolution: " & _
        objItem.DNSEnabledForWINSResolution
    Wscript.Echo "DNS Host Name: " & objItem.DNSHostName
    Wscript.Echo "DNS Server Search Order: " & objItem.DNSServerSearchOrder
    Wscript.Echo "Domain DNS Registration Enabled: " & _
        objItem.DomainDNSRegistrationEnabled
    Wscript.Echo "Forward Buffer Memory: " & objItem.ForwardBufferMemory
    Wscript.Echo "Full DNS Registration Enabled: " & _
        objItem.FullDNSRegistrationEnabled
    Wscript.Echo "Gateway Cost Metric: " & objItem.GatewayCostMetric
    Wscript.Echo "IGMP Level: " & objItem.IGMPLevel
    Wscript.Echo "Index: " & objItem.Index
    Wscript.Echo "IP Address: " & objItem.IPAddress
    Wscript.Echo "IP Connection Metric: " & objItem.IPConnectionMetric
    Wscript.Echo "IP Enabled: " & objItem.IPEnabled
    Wscript.Echo "IP Filter Security Enabled: " & _
        objItem.IPFilterSecurityEnabled
    Wscript.Echo "IP Port Security Enabled: " & _
        objItem.IPPortSecurityEnabled
    Wscript.Echo "IPSec Permit IP Protocols: " & _
        objItem.IPSecPermitIPProtocols
    Wscript.Echo "IPSec Permit TCP Ports: " & objItem.IPSecPermitTCPPorts
    Wscript.Echo "IPSec Permit UDP Ports: " & objItem.IPSecPermitUDPPorts
    Wscript.Echo "IP Subnet: " & objItem.IPSubnet
    Wscript.Echo "IP Use Zero Broadcast: " & objItem.IPUseZeroBroadcast
    Wscript.Echo "IPX Address: " & objItem.IPXAddress
    Wscript.Echo "IPX Enabled: " & objItem.IPXEnabled
    Wscript.Echo "IPX Frame Type: " & objItem.IPXFrameType
    Wscript.Echo "IPX Media Type: " & objItem.IPXMediaType
    Wscript.Echo "IPX Network Number: " & objItem.IPXNetworkNumber
    Wscript.Echo "IPX Virtual Net Number: " & objItem.IPXVirtualNetNumber
    Wscript.Echo "Keep Alive Interval: " & objItem.KeepAliveInterval
    Wscript.Echo "Keep Alive Time: " & objItem.KeepAliveTime
    Wscript.Echo "MAC Address: " & objItem.MACAddress
    Wscript.Echo "MTU: " & objItem.MTU
    Wscript.Echo "Number of Forward Packets: " & objItem.NumForwardPackets
    Wscript.Echo "PMTUBH Detect Enabled: " & objItem.PMTUBHDetectEnabled
    Wscript.Echo "PMTU Discovery Enabled: " & objItem.PMTUDiscoveryEnabled
    Wscript.Echo "Service Name: " & objItem.ServiceName
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "TCPIP Netbios Options: " & objItem.TcpipNetbiosOptions
    Wscript.Echo "TCP Maximum Connect Retransmissions: " & _
        objItem.TcpMaxConnectRetransmissions
    Wscript.Echo "TCP Maximum Data Retransmissions: " & _
        objItem.TcpMaxDataRetransmissions
    Wscript.Echo "TCP NumC onnections: " & objItem.TcpNumConnections
    Wscript.Echo "TCP Use RFC1122 Urgent Pointer: " & _
        objItem.TcpUseRFC1122UrgentPointer
    Wscript.Echo "TCP Window Size: " & objItem.TcpWindowSize
    Wscript.Echo "WINS Enable LMHosts Lookup: " & _
        objItem.WINSEnableLMHostsLookup
    Wscript.Echo "WINS Host Lookup File: " & objItem.WINSHostLookupFile
    Wscript.Echo "WINS Primary Server: " & objItem.WINSPrimaryServer
    Wscript.Echo "WINS Scope ID: " & objItem.WINSScopeID
    Wscript.Echo "WINS Secondary Server: " & objItem.WINSSecondaryServer
Next





Avatar of Rant32
Rant32

You don't happen to have any Managed switches you can log onto remotely to query the status for all ports at a time, do you? ;-)

Have a look at this piece of code, it also used WMI but a class called MSNdis_MacOptions. This only works on the local pc but can be adjusted to connect to another.
Gathered this information from https://www.experts-exchange.com/questions/21037332/Need-a-script-to-find-out-if-connected-machines-are-running-auto-full-duplex-100Mbs-or-10Mbs.html , there are other code samples there that you could use to loop through all workstations known in the domain.

It seems to return the right information, but I have only 1 pc available at the moment.

---
dim objs, obj, duplex, dtext

Set objs = GetObject("winmgmts:\\.\root\wmi").InstancesOf("MSNdis_MacOptions")
for each obj in objs
     if obj.Active = true then
             dtext = "Adapter = "& obj.InstanceName
          dtext = dtext & Chr(10) & Chr(13) & "NdisMacOptions = " & obj.NdisMacOptions
          if (obj.NdisMacOptions and 16) = 16 then
            dtext = dtext & Chr(10) & Chr(13) & "Duplex = Full"
          else
            dtext = dtext & Chr(10) & Chr(13) & "Duplex = Half"
          end if
          msgbox dtext
     end if
next
---

Avatar of davidsummers

ASKER

Unfortunatley we do not manage the switches (Another service provider) so it is not as easy as querying the switch interface.

I will try out your code and come up with one that you can use to query at the enterprise level.
Well, I don't know if I'm making sense... but if they are manageable switches, it might be worthwile to ask that service provider anyway... maybe it's takes them about 7 minutes to give you the answer... 6 minutes if they're good ;-)
I know what you are saying, but that is not an option.

I ran this code on my test machine, but it does not appear to work 100%

This is one of the results that were returned. This device I changed the Nic settings to Auto Negotiate, 10/Half and 100/Full. Everytime I ran the script I received the same result.

Adapter = Realtek RTL8139C+ Fast Ethernet NIC
NdisMacOptions = 141
Duplex = Half

Tried looking up the NdisMacOptions reference to gain a better insite as to its functions, but I could not locate any relevent articles on google.  
Also as stage 2, I will need to create another script to Set all Nics to Auto Negociate
Does it come up with a packet planner interface which returns the correct results?

Was afraid of that... since I couldn't find any references to it either, it sounds like a very undocumented feature. If only a handful of drivers expose this information through NDIS then it's not very reliable info.

If it helps any: it looks like the setting for DuplexMode is in the same registry key, mine is also in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001

The subkey changes for every NIC in the system, but maybe it would help if you got an export for this key from every system, and list duplex modes from there.

The possible options for duplexmode are listed in:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001\Ndi\params\DuplexMode\enum

You can export a registry key from the command line using

reg export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318} <filename.reg>

It returns a lot of info, but if there's no other way...

I DO know for sure, however... that if you change the DuplexMode value here:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001

To one that's listed in the enums subkey, it will also change in Device manager... so that should get you started on Stage 2 as well ;-)

For example, I changed mine from 1 to 5, and it went from Auto Negotiation to 100 Mbps Full Duplex. I have a "Realtek RTL8139/810x Family Fast Ethernet NIC" by the way.
That is the way I am heading. i am building a script to Enumerate All devices under KEY_LOCAL_MACHINE\SYSTEM\ControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}
Output that to a temp file, search the file for a Lan adapter, set that as a variable for later processing, then query the key and duplex setting and then perform a lookup on the enum key to return the duplex setting (As the enum values are different for each machine)

I will then run it in a for loop against all machines on the network using the reg query command. I'll paste it here when i am done
Excellent! Just output to a CSV or something, with:

Computername; AdapterSubkey; AdapterName; DuplexModeIndex

and another CSV with

Computername; AdapterName; DuplexModeIndex; DuplexModeSetting

The second CSV can be made into some sort of database for duplex settings for a specific NIC, because I guess those can be driver-dependent. Maybe you'll need that for Stage II ;-)
@echo off
Set PC=\\%1
Set TMP1=c:\temp\temp1.txt

REM Comms test to see if Machine is up.
ping -n 1 %1 | findstr /I "Reply From" && GOTO UP
goto Down

:UP
REM Keys that will be searched
Set SubKey0=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0000
Set SubKey1=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001
Set SubKey2=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0002
Set SubKey3=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0003
Set SubKey4=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0004
Set SubKey5=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0005
Set SubKey6=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0006
Set SubKey7=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0007
Set SubKey8=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0008
Set SubKey9=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0009
Set SubKey10=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0010
Set SubKey11=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0011
Set SubKey12=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0012
Set SubKey13=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0013
Set SubKey14=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0014
Set SubKey15=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0015
Set SubKey16=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0016
Set SubKey17=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0017
Set SubKey18=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0018
Set SubKey19=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0019

REM Locating the BusTpe 5 (This is a Lan adapter BusType) and setting a new variable

for /f "Tokens=1,2,3 delims= " %%a in ('Reg Query %PC%\%SubKey0% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check2)
:Check2
IF "%LanBustype%"=="5" (set NetKey=%SubKey0% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey1% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check3)
:Check3
IF "%LanBustype%"=="5" (set NetKey=%SubKey1% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey2% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check4)
:Check4
IF "%LanBustype%"=="5" (set NetKey=%SubKey2% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey3% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check5)
:Check5
IF "%LanBustype%"=="5" (set NetKey=%SubKey3% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey4% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check6)
:Check6
IF "%LanBustype%"=="5" (set NetKey=%SubKey4% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey5% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check7)
:Check7
IF "%LanBustype%"=="5" (set NetKey=%SubKey5% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey6% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check8)
:Check8
IF "%LanBustype%"=="5" (set NetKey=%SubKey6% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey7% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check9)
:Check9
IF "%LanBustype%"=="5" (set NetKey=%SubKey7% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey8% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check10)
:Check10
IF "%LanBustype%"=="5" (set NetKey=%SubKey8% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey9% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check11)
:Check11
IF "%LanBustype%"=="5" (set NetKey=%SubKey9% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey10% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check12)
:Check12
IF "%LanBustype%"=="5" (set NetKey=%SubKey10% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey11% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check13)
:Check13
IF "%LanBustype%"=="5" (set NetKey=%SubKey11% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey12% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check14)
:Check14
IF "%LanBustype%"=="5" (set NetKey=%SubKey12% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey13% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check15)
:Check15
IF "%LanBustype%"=="5" (set NetKey=%SubKey13% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey14% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check16)
:Check16
IF "%LanBustype%"=="5" (set NetKey=%SubKey14% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey15% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check17)
:Check17
IF "%LanBustype%"=="5" (set NetKey=%SubKey15% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey16% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check18)
:Check18
IF "%LanBustype%"=="5" (set NetKey=%SubKey16% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey17% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check19)
:Check19
IF "%LanBustype%"=="5" (set NetKey=%SubKey17% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey18% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check20)
:Check20
IF "%LanBustype%"=="5" (set NetKey=%SubKey18% & GOTO KeyEnum)
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%SubKey19% /v BusType') do set LanBustype=%%c
IF ERRORLEVEL=0 (goto Check21)
:Check21
IF "%LanBustype%"=="5" (set NetKey=%SubKey19% & GOTO KeyEnum)

GOTO Error1

:KeyEnum
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%NetKey% /v SpeedDuplex') do set DuplexMode=%%c
for /f "delims=" %%a in ('Reg Query %PC%\%NetKey% /v DriverDesc') do set DriverDesc=%%a
Reg query %PC%\%Netkey:~0,-1%\ndi\params\speedduplex\enum >> %TMP1%
for /f "Tokens=1,2,3"  %%a in ('findstr /c:"    %DuplexMode%    REG_SZ" %TMP1%') do set DuplexSetting=%%c

Echo %PC%,%DuplexSetting%,%DriverDesc:~28%,%netkey% >> Results.txt

goto End

:Down
echo %PC%, is Down >> Results.txt
goto end

:Error1
echo %PC%, unable to enumerate the network adapter key >> Results.txt
goto end

:End

Set TMP1=
IF Exist c:\Temp\Temp1.txt Del c:\Temp\Temp1.txt
Set PC=
Set LanBustype=
Set DuplexSetting=
Set Duplexmode=
Set DriverDesc=
Set netkey=
Set SubKey0=
Set SubKey1=
Set SubKey2=
Set SubKey3=
Set SubKey4=
Set SubKey5=
Set SubKey6=
Set SubKey7=
Set SubKey8=
Set SubKey9=
Set SubKey10=
Set SubKey11=
Set SubKey12=
Set SubKey13=
Set SubKey14=
Set SubKey15=
Set SubKey16=
Set SubKey17=
Set SubKey18=
Set SubKey19=
This is what I come up with, pretty ugly, but that is Batch for you.

This locates the Bustype=5 (Key and value only found on Network adapters) key under all of the possible regkeys for network adapters and then enumerates the duplex settings taking the duplex value from the network cards own entry.

Note this will only work for Intel Cards, as other manufactures use a different key name for the Duplex settings.
for /f "Tokens=1,2,3" %%a in ('Reg Query %PC%\%NetKey% /v SpeedDuplex') do set DuplexMode=%%c
So this line might need to be changed depending on the NIC

To run this, I placed the whole text into a batch file called LinkEnum.bat and executed it from a command line using the following FOR loop

FOR /f %a in (PCS.txt) do call LinkEnum.bat %a

Where (PCS.txt) is a list of machines taken from AD

The results line looks like this

PCno1, Auto,Intel(R) PRO/100 VE Network Connection,HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0005  

Well, I hope this works for you, if it does we could pretty things up and put some code together.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer