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

Help - Need to enable/disable network connection via command line

58 views
Skip to first unread message

FD

unread,
Dec 15, 2002, 9:27:52 AM12/15/02
to
Help,

I can't find a command line tool in Windows 2000 Professional which will
allow me to disable and enable a network adapter connection.

I need to write a batch file to periodically disable, then re-enable a
network card adapter connection.

Also, is there a good resource for all Windows 2000 command line tools
besides Windows Help?

FD


Ritchie

unread,
Dec 15, 2002, 11:42:58 AM12/15/02
to
"FD" <no_replies_please> wrote in message news:2FKdnfdjUPr...@comcast.com...

> I need to write a batch file to periodically disable, then re-enable a
> network card adapter connection.

Win2000 comes with the NetSh.exe.

Supposedly the syntax for disabling "Local Area Connection" is something like:-

netsh interface set interface name="Local Area Connection" admin=DISABLED

or

netsh interface set interface "Local Area Connection" DISABLED

But you might get an error message (I did) as described in the KB Article:-

Error Message When You Use Netsh.exe to Enable or Disable a Network Adapter
http://support.microsoft.com/default.aspx?scid=kb;en-us;262265

In which case do as the article suggests and change the IP address settings. I
used this command which seem quite effective in disabling the interface (its
one long line):-

netsh interface ip set address "Local Area Connection"
static 10.0.0.1 255.0.0.0 10.0.0.1 1

If the interface was using DHCP, it can be enabled using:-

netsh interface ip set address "Local Area Connection" dhcp

Other references:
How to Use the Netsh.exe Tool and Command-Line Switches
http://support.microsoft.com/default.aspx?scid=kb;en-us;242468

How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;257748

> Also, is there a good resource for all Windows 2000 command line tools
> besides Windows Help?

You've found it, welcome! Also checkout 'alt.msdos.batch.nt'.
Here's a link to a recent post; it has a script to generate an indexed file
in html format of most commands in NT4/W2K/XP and any 'custom' commands you
decide to add to the script, such as NETSH:-

http://groups.google.com/groups?selm=at32hc$10aa3g$1...@ID-156657.news.dfncis.de

--
Ritchie


FD

unread,
Dec 15, 2002, 7:06:02 PM12/15/02
to
Thanks, but I wanted to actually bounce the interface - I seem to loose my
wireless connected from time to time and I wanted to write a batch script.

Anyway, the commands as you specified always result in a syntax error.
Here's what I typed for my interface named wireless

netsh interface set interface name=wireless admin=disabled

It just echoed back the syntax options indicating I had the wrong syntax.
Also, since this is not suppposed to work for dedicated options, how come I
get the following error when I try connecting with a VPN or RAS connection:

"An interface with this name is not registered with the router."

FD


"Ritchie" <qiournvdlirh...@hotmail.com> wrote in message
news:atibgn$1485pi$1...@ID-156657.news.dfncis.de...

Torgeir Bakken (MVP)

unread,
Dec 15, 2002, 9:07:07 PM12/15/02
to
FD wrote:

> Help,
>
> I can't find a command line tool in Windows 2000 Professional which will
> allow me to disable and enable a network adapter connection.
>
> I need to write a batch file to periodically disable, then re-enable a
> network card adapter connection.

Hi

If NetSh.exe didn't do it for you, here are a couple of alternatives that you
could try:


============================================================
Shell.Application/VBScript

From: Michael Harris (mik...@mvps.org)
Subject: Re: How to disable-Enable Local area Connection via script
Newsgroups: microsoft.public.scripting.vbscript
Date: 2002-03-25 11:36:10 PST
http://groups.google.com/groups?threadm=OcFYOQD1BHA.2848%40tkmsftngp05


============================================================
Devcon.exe maybe?

Take a look at this thread:
From: Jon (jo...@stargatefilms.com)
Subject: Enable/disable network adapter
Newsgroups: microsoft.public.win2000.cmdprompt.admin
Date: 2002-02-28 11:43:59 PST
http://groups.google.com/groups?hl=en&th=5c30bf627c5883ae&rnum=12


For more information about devcon.exe (W2K/XP DDK)

Message-ID: <ebVUeG2lBHA.1964@tkmsftngp07>
From: Stephane Barizien (NOSP...@ocegr.fr)
Subject: Re: Command-line equivalent to Device Manager's "Scan for hardware
changes"
Newsgroups: microsoft.public.win2000.cmdprompt.admin,
microsoft.public.win32.programmer.wmi
Date: 2002-01-07 02:00:08 PST
http://groups.google.com/groups?hl=en&selm=ebVUeG2lBHA.1964%40tkmsftngp07

- and -
this MS Knowledge Base article:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q311272

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway


Dean Wells

unread,
Dec 16, 2002, 8:24:02 AM12/16/02
to
I've pasted a post I made a while back to similar question which
included the necessary devcon.exe syntax to do as you ask -

[PASTE]
By modifying the relevant registry value for
the NIC in question, disabling and then re-enabling the NIC allowed me
to change the link state from the command line. Please fully read my
notes below to ensure you understand how this works.

The NIC friendly name is maintained beneath -

HKLM\System\CCS\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\<
ID>\Connection\Name (REG_SZ) = FriendlyName

... and provides you with the means to cross reference how you see the
NIC to how the OS see's the NIC.

The <ID> from the line above then matches NetCfgInstanceId (REG_SZ)
value within <instanceID> key below -

HKLM\System\CCS\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\<in
stanceID>

The following registry value controls the LinkSelection state of a
particular NIC, in this case a 3COM -

HKLM\System\CCS\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\<in
stanceID>\LinkSelection (REG_SZ)

* NOTE - MediaType and DuplexMode are also examples of the value used to
maintain the link state.
The value used is vendor specific and makes automation
of this task a little difficult through shell script.

The MatchingDeviceID (REG_SZ) value beneath this key contains the device
ID syntax desired by DEVCON.EXE

DEVCON Syntax -

devcon disable =net pci\ven_10b7^&DEV_6056^&SUBSYS_635610B7^&REV_20
devcon enable =net pci\ven_10b7^&DEV_6056^&SUBSYS_635610B7^&REV_20

Using registry export, file querying, file modify and registry import
combined with the above DEVCON syntax to disable and then re-enable the
NIC, I successfully re-configured the link state. As I mentioned, the
registry settings are vendor specific so you'll need to ensure you know
the vendor value name (which may well differ from NIC model to NIC
model) before modifying the registry. The driver class ID are well-known
and should not alter from system to system.

It is also important to note that DEVCON treats the device IDs as
wildcard prefixes, when supplying the device IDs above the ampersand
symbols are first interpreted by CMD.EXE as command delimiters and need
to be abstracted (or escaped) by prefixing each ampersand with a ^. If
you DO NOT do this, you may find that you disable many devices due to
the fact that they're all prefixed with the same ID.

[/PASTE]

The syntax is within the above pasted text prefixed by netcon disable or
enable.

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
dwe...@msetechnology.com
[[ Please respond to the Newsgroup only ]]


"FD" <no_replies_please> wrote in message
news:2FKdnfdjUPr...@comcast.com...

FD

unread,
Dec 16, 2002, 6:53:26 PM12/16/02
to
Torgeir,

I went with the VB Script - mainly cause it worked the first time I tried
it!!!!!

Much Thanks.

Frank


"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3DFD354B...@hydro.com...

0 new messages