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\CurrentControl Set\Contro l\Class\{4 D36E972-E3 25-11CE-BF C1-08002BE 10318}\000 1\Ndi\Para ms\DuplexM ode\enum\1 Auto Negotiation
HKLM\System\CurrentControl Set\Contro l\Class\{4 D36E972-E3 25-11CE-BF C1-08002BE 10318}\000 1\Ndi\Para ms\DuplexM ode\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("S elect * 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.MaxNumberControlle d
  Wscript.Echo "Maximum Speed: " & objItem.MaxSpeed
  Wscript.Echo "Name: " & objItem.Name
  Wscript.Echo "Net Connection ID: " & objItem.NetConnectionID
  Wscript.Echo "Net Connection Status: " & objItem.NetConnectionStatu s
  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_NetworkAdapterConfig uration")
For Each objItem in colItems
  Wscript.Echo "ARP Always Source Route: " & objItem.ArpAlwaysSourceRou te
  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.DeadGWDetectEnable d
  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.DNSDomainSuffixSea rchOrder
  Wscript.Echo "DNS Enabled For WINS Resolution: " & _
    objItem.DNSEnabledForWINSR esolution
  Wscript.Echo "DNS Host Name: " & objItem.DNSHostName
  Wscript.Echo "DNS Server Search Order: " & objItem.DNSServerSearchOrd er
  Wscript.Echo "Domain DNS Registration Enabled: " & _
    objItem.DomainDNSRegistrat ionEnabled
  Wscript.Echo "Forward Buffer Memory: " & objItem.ForwardBufferMemor y
  Wscript.Echo "Full DNS Registration Enabled: " & _
    objItem.FullDNSRegistratio nEnabled
  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.IPFilterSecurityEn abled
  Wscript.Echo "IP Port Security Enabled: " & _
    objItem.IPPortSecurityEnab led
  Wscript.Echo "IPSec Permit IP Protocols: " & _
    objItem.IPSecPermitIPProto cols
  Wscript.Echo "IPSec Permit TCP Ports: " & objItem.IPSecPermitTCPPort s
  Wscript.Echo "IPSec Permit UDP Ports: " & objItem.IPSecPermitUDPPort s
  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.IPXVirtualNetNumbe r
  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.PMTUBHDetectEnable d
  Wscript.Echo "PMTU Discovery Enabled: " & objItem.PMTUDiscoveryEnabl ed
  Wscript.Echo "Service Name: " & objItem.ServiceName
  Wscript.Echo "Setting ID: " & objItem.SettingID
  Wscript.Echo "TCPIP Netbios Options: " & objItem.TcpipNetbiosOption s
  Wscript.Echo "TCP Maximum Connect Retransmissions: " & _
    objItem.TcpMaxConnectRetra nsmissions
  Wscript.Echo "TCP Maximum Data Retransmissions: " & _
    objItem.TcpMaxDataRetransm issions
  Wscript.Echo "TCP NumC onnections: " & objItem.TcpNumConnections
  Wscript.Echo "TCP Use RFC1122 Urgent Pointer: " & _
    objItem.TcpUseRFC1122Urgen tPointer
  Wscript.Echo "TCP Window Size: " & objItem.TcpWindowSize
  Wscript.Echo "WINS Enable LMHosts Lookup: " & _
    objItem.WINSEnableLMHostsL ookup
  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.WINSSecondaryServe r
Next
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\CurrentControl
HKLM\System\CurrentControl
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.
**************************
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" &Â strComputer &Â "\root\cimv2")
Set colItems = objWMIService.ExecQuery("S
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.MaxNumberControlle
  Wscript.Echo "Maximum Speed: " & objItem.MaxSpeed
  Wscript.Echo "Name: " & objItem.Name
  Wscript.Echo "Net Connection ID: " & objItem.NetConnectionID
  Wscript.Echo "Net Connection Status: " & objItem.NetConnectionStatu
  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
**************************
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" &Â strComputer &Â "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
  ("Select * from Win32_NetworkAdapterConfig
For Each objItem in colItems
  Wscript.Echo "ARP Always Source Route: " & objItem.ArpAlwaysSourceRou
  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.DeadGWDetectEnable
  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.DNSDomainSuffixSea
  Wscript.Echo "DNS Enabled For WINS Resolution: " & _
    objItem.DNSEnabledForWINSR
  Wscript.Echo "DNS Host Name: " & objItem.DNSHostName
  Wscript.Echo "DNS Server Search Order: " & objItem.DNSServerSearchOrd
  Wscript.Echo "Domain DNS Registration Enabled: " & _
    objItem.DomainDNSRegistrat
  Wscript.Echo "Forward Buffer Memory: " & objItem.ForwardBufferMemor
  Wscript.Echo "Full DNS Registration Enabled: " & _
    objItem.FullDNSRegistratio
  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.IPFilterSecurityEn
  Wscript.Echo "IP Port Security Enabled: " & _
    objItem.IPPortSecurityEnab
  Wscript.Echo "IPSec Permit IP Protocols: " & _
    objItem.IPSecPermitIPProto
  Wscript.Echo "IPSec Permit TCP Ports: " & objItem.IPSecPermitTCPPort
  Wscript.Echo "IPSec Permit UDP Ports: " & objItem.IPSecPermitUDPPort
  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.IPXVirtualNetNumbe
  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.PMTUBHDetectEnable
  Wscript.Echo "PMTU Discovery Enabled: " & objItem.PMTUDiscoveryEnabl
  Wscript.Echo "Service Name: " & objItem.ServiceName
  Wscript.Echo "Setting ID: " & objItem.SettingID
  Wscript.Echo "TCPIP Netbios Options: " & objItem.TcpipNetbiosOption
  Wscript.Echo "TCP Maximum Connect Retransmissions: " & _
    objItem.TcpMaxConnectRetra
  Wscript.Echo "TCP Maximum Data Retransmissions: " & _
    objItem.TcpMaxDataRetransm
  Wscript.Echo "TCP NumC onnections: " & objItem.TcpNumConnections
  Wscript.Echo "TCP Use RFC1122 Urgent Pointer: " & _
    objItem.TcpUseRFC1122Urgen
  Wscript.Echo "TCP Window Size: " & objItem.TcpWindowSize
  Wscript.Echo "WINS Enable LMHosts Lookup: " & _
    objItem.WINSEnableLMHostsL
  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.WINSSecondaryServe
Next
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.
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 ;-)
ASKER
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. Â
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. Â
ASKER
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\ CurrentCon trolSet\Co ntrol\Clas s\{4D36E97 2-E325-11C E-BFC1-080 02bE10318} \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\C lass\{4D36 E972-E325- 11CE-BFC1- 08002bE103 18}\0001\N di\params\ DuplexMode \enum
You can export a registry key from the command line using
reg export HKEY_LOCAL_MACHINE\SYSTEM\ CurrentCon trolSet\Co ntrol\Clas s\{4D36E97 2-E325-11C E-BFC1-080 02bE10318} <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\C lass\{4D36 E972-E325- 11CE-BFC1- 08002bE103 18}\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.
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\
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\
You can export a registry key from the command line using
reg export HKEY_LOCAL_MACHINE\SYSTEM\
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\
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.
ASKER
That is the way I am heading. i am building a script to Enumerate All devices under KEY_LOCAL_MACHINE\SYSTEM\C ontrolSet\ Control\Cl ass\{4D36E 972-E325-1 1CE-BFC1-0 8002bE1031 8}
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
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 ;-)
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 ;-)
ASKER
@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\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 000
Set SubKey1=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 001
Set SubKey2=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 002
Set SubKey3=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 003
Set SubKey4=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 004
Set SubKey5=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 005
Set SubKey6=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 006
Set SubKey7=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 007
Set SubKey8=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 008
Set SubKey9=HKEY_LOCAL_MACHINE \SYSTEM\Cu rrentContr olSet\Cont rol\Class\ {4D36E972- E325-11CE- BFC1-08002 bE10318}\0 009
Set SubKey10=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0010
Set SubKey11=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0011
Set SubKey12=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0012
Set SubKey13=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0013
Set SubKey14=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0014
Set SubKey15=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0015
Set SubKey16=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0016
Set SubKey17=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0017
Set SubKey18=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 0018
Set SubKey19=HKEY_LOCAL_MACHIN E\SYSTEM\C urrentCont rolSet\Con trol\Class \{4D36E972 -E325-11CE -BFC1-0800 2bE10318}\ 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\pa rams\speed duplex\enu m >>Â %TMP1%
for /f "Tokens=1,2,3" Â %%a in ('findstr /c:" Â Â %DuplexMode% Â Â REG_SZ" %TMP1%') do set DuplexSetting=%%c
Echo %PC%,%DuplexSetting%,%Driv erDesc:~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=
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
Set SubKey1=HKEY_LOCAL_MACHINE
Set SubKey2=HKEY_LOCAL_MACHINE
Set SubKey3=HKEY_LOCAL_MACHINE
Set SubKey4=HKEY_LOCAL_MACHINE
Set SubKey5=HKEY_LOCAL_MACHINE
Set SubKey6=HKEY_LOCAL_MACHINE
Set SubKey7=HKEY_LOCAL_MACHINE
Set SubKey8=HKEY_LOCAL_MACHINE
Set SubKey9=HKEY_LOCAL_MACHINE
Set SubKey10=HKEY_LOCAL_MACHIN
Set SubKey11=HKEY_LOCAL_MACHIN
Set SubKey12=HKEY_LOCAL_MACHIN
Set SubKey13=HKEY_LOCAL_MACHIN
Set SubKey14=HKEY_LOCAL_MACHIN
Set SubKey15=HKEY_LOCAL_MACHIN
Set SubKey16=HKEY_LOCAL_MACHIN
Set SubKey17=HKEY_LOCAL_MACHIN
Set SubKey18=HKEY_LOCAL_MACHIN
Set SubKey19=HKEY_LOCAL_MACHIN
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\pa
for /f "Tokens=1,2,3" Â %%a in ('findstr /c:" Â Â %DuplexMode% Â Â REG_SZ" %TMP1%') do set DuplexSetting=%%c
Echo %PC%,%DuplexSetting%,%Driv
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=
ASKER
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_MACH INE\SYSTEM \CurrentCo ntrolSet\C ontrol\Cla ss\{4D36E9 72-E325-11 CE-BFC1-08 002bE10318 }\0005 Â
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_MACH
Well, I hope this works for you, if it does we could pretty things up and put some code together.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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:\\.\ro
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
---