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

Change Nic Speed with batch file

1,789 views
Skip to first unread message

dra...@gmail.com

unread,
Dec 17, 2013, 2:44:01 AM12/17/13
to
Does anybody know of a code I can put in a batch file to change the Nic Speed easily? I have a user that needs to be 100 full at the office but Auto Negotiate at home..
I can't have him go into the network settings everytime, so Batch file would be an easy fix.

Stanley Daniel de Liver

unread,
Dec 17, 2013, 6:48:27 AM12/17/13
to
yup, use a simple reg import.

--
It's a money /life balance.

19ma...@gmail.com

unread,
Dec 18, 2013, 10:28:11 AM12/18/13
to
On Tuesday, December 17, 2013 2:44:01 AM UTC-5, dra...@gmail.com wrote:
> Does anybody know of a code I can put in a batch file to change the Nic Speed easily? I have a user that needs to be 100 full at the office but Auto Negotiate at home..
>
> I can't have him go into the network settings everytime, so Batch file would be an easy fix.

Yes, you can do it via the registry. I've written a script to do this but it's specific to the model of your nic and the name of your connection. You'll have to play with the settings and key names a bit but this should get you on the right path.

@echo off
setlocal
set key=HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0007

FOR /F "tokens=3" %%A IN ('REG QUERY "%Key%" /v *SpeedDuplex') DO SET Speed=%%A
if %Speed% EQU 0 (
reg add %key% /v *SpeedDuplex /d 6 /t REG_SZ /f
netsh interface set interface "Local Area Connection 2" DISABLED
netsh interface set interface "Local Area Connection 2" ENABLED
echo Connection set to 100 Mb/Full Duplex
) else (
reg add %key% /v *SpeedDuplex /d 0 /t REG_SZ /f
netsh interface set interface "Local Area Connection 2" DISABLED
netsh interface set interface "Local Area Connection 2" ENABLED
echo Connection set to Auto
)
Ping -n 4 localhost>nul

foxidrive

unread,
Dec 18, 2013, 6:05:20 PM12/18/13
to
On 19/12/2013 02:28, 19ma...@gmail.com wrote:
> On Tuesday, December 17, 2013 2:44:01 AM UTC-5, dra...@gmail.com wrote:
>>> Does anybody know of a code I can put in a batch file to change the Nic Speed easily? I have a
>>> user that needs to be 100 full at the office but Auto Negotiate at home..
>>>
>>> I can't have him go into the network settings everytime, so Batch file would be an easy fix.

> Yes, you can do it via the registry. I've written a script to do this but it's specific to the model
> of your nic and the name of your connection. You'll have to play with the settings and key names a bit
> but this should get you on the right path.


I'm just following up to say that you'll need to check the \0007 and the "Local Area Connection 2" which
can change on different machines.

I haven't tested this myself - I wonder if it will need a reboot?

JJ

unread,
Dec 18, 2013, 8:50:42 PM12/18/13
to
On Thu, 19 Dec 2013 10:05:20 +1100, foxidrive wrote:
> I'm just following up to say that you'll need to check the \0007 and the "Local Area Connection 2" which
> can change on different machines.
>
> I haven't tested this myself - I wonder if it will need a reboot?

It depends on the driver.
I found that, a view crappy drivers for onboard NICs may complains that it
needs system reboot when unloaded.
The effect won't be applied until the driver is completely unloaded from the
system, then loaded again.

Stanley Daniel de Liver

unread,
Dec 19, 2013, 8:39:12 AM12/19/13
to
On Wed, 18 Dec 2013 23:05:20 -0000, foxidrive <foxi...@server.invalid>
wrote:

> On 19/12/2013 02:28, 19ma...@gmail.com wrote:
>> On Tuesday, December 17, 2013 2:44:01 AM UTC-5, dra...@gmail.com wrote:
>>>> Does anybody know of a code I can put in a batch file to change the
>>>> Nic Speed easily? I have a
>>>> user that needs to be 100 full at the office but Auto Negotiate at
>>>> home..
>>>>
>>>> I can't have him go into the network settings everytime, so Batch
>>>> file would be an easy fix.
>
>> Yes, you can do it via the registry. I've written a script to do this
>> but it's specific to the model
>> of your nic and the name of your connection. You'll have to play with
>> the settings and key names a bit
>> but this should get you on the right path.
>
>
> I'm just following up to say that you'll need to check the \0007 and the
> "Local Area Connection 2" which
> can change on different machines.
>
> I haven't tested this myself - I wonder if it will need a reboot?

IIRC you can "net stop server" and "net start server"
to reinitialise the NIC without rebooting.

>
>
>
> @echo off
> setlocal
> set
> key=HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0007
>
> FOR /F "tokens=3" %%A IN ('REG QUERY "%Key%" /v *SpeedDuplex') DO SET
> Speed=%%A
> if %Speed% EQU 0 (
> reg add %key% /v *SpeedDuplex /d 6 /t REG_SZ /f
> netsh interface set interface "Local Area Connection 2" DISABLED
> netsh interface set interface "Local Area Connection 2" ENABLED
> echo Connection set to 100 Mb/Full Duplex
> ) else (
> reg add %key% /v *SpeedDuplex /d 0 /t REG_SZ /f
> netsh interface set interface "Local Area Connection 2" DISABLED
> netsh interface set interface "Local Area Connection 2" ENABLED
> echo Connection set to Auto
> )
> Ping -n 4 localhost>nul


0 new messages