Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Changing NIC speed and duplex option
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



Report this thread to moderator Post Follow-up to this message
Old Post
Tom Ker
12-07-05 11:56 PM


Re: Changing NIC speed and duplex option
"Tom Ker" <thomasDOTkerA@Thighmark.com> wrote in message
news:%23s0YCS1%23FHA.360@TK2MSFTNGP09.phx.gbl...
> 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
>

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-08002be1031
8}"

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



Report this thread to moderator Post Follow-up to this message
Old Post
B-Mann
12-08-05 02:55 AM


Re: Changing NIC speed and duplex option
Thanks, B-Mann, I'll take a look at it.



Report this thread to moderator Post Follow-up to this message
Old Post
Tom Ker
12-08-05 11:57 PM


Re: Changing NIC speed and duplex option
I have a very simple solution which implies to know its environment well. Th
is example modifies in Auto (strValue = 0) for Intel Nic(SpeedDuplex) and Br
oadcom 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-BFC
1-08002be10318}"

oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys
   
   	' Cartes Intel - SpeedDuplex 
    oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey, "Spee
dDuplex", strValue
		If strValue <> 0 Then
    	strValue = 0
    	oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey, "Spee
dDuplex", strValue
    	
    End If
    
    ' Cartes Broadcom - RequestedMediaType 
 		oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey, "Reque
stedMediaType", strValue
 		If strValue <> 0 Then
    	strValue = 0
    	oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey, "Requ
estedMediaType", strValue
    	
    End If

Next

Report this thread to moderator Post Follow-up to this message
Old Post
oriba68
07-26-07 02:53 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

VBScript archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:27 AM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.