Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing NIC speed and duplex option

98 views
Skip to first unread message

Tom Ker

unread,
Dec 7, 2005, 12:34:41 PM12/7/05
to
We've got a project about to start to change all our PCs from 10/Full to
Auto. Thankfully we only have 3 or 4 different NICs in our environment, but
we have 1,000s of them so I want to write a script that will do the change
for me.

Can someone point me to some code to get me started with this. please?

Thanks,

Tom


B-Mann

unread,
Dec 7, 2005, 8:24:33 PM12/7/05
to

"Tom Ker" <thomas...@Thighmark.com> wrote in message
news:%23s0YCS1%23FH...@TK2MSFTNGP09.phx.gbl...

Tom,

I use the following script to set our NIC's to 100/FULL, I'm sure it can
be adapted to set yours to Auto.

The script scans the registry to obtain each NIC that is installed. For each
NIC that is found, the script will locate and apply the appropriate registry
value you define in a separate .ini file (SpdDplx.ini). The .ini file
contains the registry value for each NIC based on the vendor ID and device
ID as found in the ComponentID registry value for a given NIC. Here is my
example, keep in mind that the values listed in the .ini file are for
setting the NIC's to 100/FULL, you will need to add/edit your entries for
the NIC's in your environment to the values that will set the NIC's to
Auto.

SpdDplx.ini
========
[14E41645]
;Broadcom NetXtreme Gigabit Ethernet (BCM5701)
;ComponentId=PCI\VEN_14E4&DEV_1645
RequestedMediaType=6

[14E41659]
;Broadcom NetXtreme Gigabit Ethernet PCI Express (BCM5750A1)
;ComponentId=PCI\VEN_14E4&DEV_1659
RequestedMediaType=6

[14E416A6]
;Broadcom NetXtreme Gigabit Ethernet (BCM5702X)
;ComponentId=PCI\VEN_14E4&DEV_16A6
RequestedMediaType=6

[14E41644]
;Broadcom NetXtreme Gigabit Ethernet (BCM5700/5401)
;ComponentId=PCI\VEN_14E4&DEV_1644
RequestedMediaType=6

[14E41648]
;Broadcom NetXtreme Gigabit Ethernet (BCM5704)
;ComponentId=PCI\VEN_14E4&DEV_1648
RequestedMediaType=6

[14E416A7]
;Broadcom NetXtreme Gigabit Ethernet
;ComponentId=PCI\VEN_14E4&DEV_16A7
RequestedMediaType=6

[14E416C7]
;Broadcom NetXtreme Gigabit Ethernet
;ComponentId=PCI\VEN_14E4&DEV_16C7
RequestedMediaType=6

[14E416A8]
;Broadcom NetXtreme Gigabit Ethernet (BCM5704S)
;ComponentId=PCI\VEN_14E4&DEV_16A8
RequestedMediaType=6

[10B79805]
;3Com EtherLink Server 10/100 PCI (3C980C-TXM)
;ComponentId=PCI\VEN_10b7&DEV_9805
Duplexmode=FullDuplex
media=100FULL

[10B79800]
;3Com EtherLink Server 10/100 PCI (3C980B-TX)
;ComponentId=PCI\VEN_10b7&DEV_9800
Duplexmode=FullDuplex
media=100FULL

[10EC8139]
;Realtek RTL8139 Family PCI Fast Ethernet NIC
;ComponentId=PCI\VEN_10EC&DEV_8139
DuplexMode=5

[80861004]
;Intel PRO/1000 Gigabit Desktop Adapter
;ComponentId=PCI\VEN_8086&DEV_1004
SpeedDuplex=5

[80861008]
;Intel PRO/1000 Gigabit Desktop Adapter
;ComponentId=PCI\VEN_8086&DEV_1008
SpeedDuplex=5

[80861009]
;Intel PRO/1000 Gigabit Desktop Adapter
;ComponentId=PCI\VEN_8086&DEV_1009
SpeedDuplex=5

[8086100C]
;Intel PRO/1000 Gigabit Desktop Adapter
;ComponentId=PCI\VEN_8086&DEV_100C
SpeedDuplex=5

[8086100E]
;Intel PRO/1000 Gigabit Desktop Adapter
;ComponentId=PCI\VEN_8086&DEV_100E
SpeedDuplex=5

[80861010]
;Intel PRO/1000 Gigabit Desktop Adapter
;ComponentId=PCI\VEN_8086&DEV_1010
SpeedDuplex=5

[10222000]
;AMD PCNET Family Ethernet Adapter (PCI)
;ComponentId=PCI\VEN_1022&DEV_2000
EXTPHY=2

[11063106]
;VIA VT6105M Rhine III Management Adapter
;ComponentId=PCI\VEN_1106&DEV_3106
ConnectionType=2

[11063043]
;VIA VT86C100A Fast Ethernet Adapter
;ComponentId=PCI\VEN_1106&DEV_3043
ConnectionType=2

[11063065]
;VIA PCI 10/100Mb Fast Ethernet Adapter
;ComponentId=PCI\VEN_1106&DEV_3065
ConnectionType=2

[12829102]
;DAVICOM 9102-Based PCI Fast Ethernet Adapter
;ComponentId=PCI\VEN_1282&DEV_9102
ConnectionType=4

[10110009]
;DC21x4 Based Network Adapter Driver
;ComponentId=PCI\VEN_1011&DEV_0009
ConnectionType=9

[10B79200]
;3Com EtherLink XL 10/100 PCI For Complete PC Management
;ComponentId=PCI\VEN_10B7&DEV_9200
Media_type=100FULL

SetSpeed.vbs
==========
Const HKLM = &H80000002

strComputer = "."
Set fso = CreateObject("Scripting.FileSystemObject")
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")
sNetPath =
"System\Currentcontrolset\Control\Class\{4D36E972-E325-11CE-BFC1-08002be10318}"

SetSpeedDuplex()

Sub SetSpeedDuplex()
Dim section, strValue, subkey, arrSubKeys

objRegistry.EnumKey HKLM, sNetPath, arrSubKeys
For Each subkey In arrSubKeys
objRegistry.GetStringvalue HKLM, sNetPath & "\" & subkey, "ComponentId",
strValue
if not isnull(strValue) then
strValue = lcase(strValue)
section = left(replace(replace(strValue, "pci\ven_", ""), "&dev_",
""), 8)
ReadDuplexIni section, subkey
end if
Next
End Sub

Sub ReadDuplexIni(section, subkey)
Dim ini, line, file

file = "spddplx.ini"
If fso.FileExists(file) Then
Set ini = fso.OpenTextFile(file, 1, False)
Do While ini.AtEndOfStream = False
line = ini.ReadLine
If lcase(line) = "[" & lcase(section) & "]" Then
line = ini.ReadLine
Do While Left(line, 1) <> "["
If left(line, 1) <> ";" and len(line) > 0 Then
UpdateReg line, subkey
End If
If ini.AtEndOfStream Then Exit Do
line = ini.ReadLine
Loop
Exit Do
End If
Loop
ini.Close
End If
End Sub

Sub UpdateReg(line, subkey)
Dim lRC

key = split(line, "=")
lRC=objRegistry.SetStringValue(HKLM, sNetPath & "\" & subkey, key(0),
key(1))
End Sub

Hope this helps,

B-Mann


Tom Ker

unread,
Dec 8, 2005, 11:22:06 AM12/8/05
to
Thanks, B-Mann, I'll take a look at it.


oriba68

unread,
Jul 26, 2007, 10:53:09 AM7/26/07
to

I have a very simple solution which implies to know its environment
well. This example modifies in Auto (strValue = 0) for Intel
Nic(SpeedDuplex) and Broadcom NIC (RequestedMediaType).

Can be used with computer GPO.

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _

strComputer & "\root\default:StdRegProv")

strKeyPath =


"System\Currentcontrolset\Control\Class\{4D36E972-E325-11CE-BFC1-08002be10318}"

oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys

' Cartes Intel - SpeedDuplex
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey,
"SpeedDuplex", strValue
If strValue <> 0 Then
strValue = 0
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey,
"SpeedDuplex", strValue

End If

' Cartes Broadcom - RequestedMediaType
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey,
"RequestedMediaType", strValue
If strValue <> 0 Then
strValue = 0
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey,
"RequestedMediaType", strValue

End If

Next

--
oriba68
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

0 new messages