The simple way to disable/enable LAN from command prompt, with a batch file, using devcon.exe

Discussion in 'Microsoft Windows 2000 Networking' started by setup21@gmx.de, Apr 16, 2006.

  1. Guest

    , Apr 16, 2006
    #1
    1. Advertisements

  2. Unfortunately, this tip will only work for folks who have the same network
    adapter that you do.

    --
    Richard G. Harper [MVP Shell/User]
    * PLEASE post all messages and replies in the newsgroups
    * for the benefit of all. Private mail is usually not replied to.
    * My website, such as it is ... http://rgharper.mvps.org/
    * HELP us help YOU ... http://www.dts-l.org/goodpost.htm


    <> wrote in message
    news:...
    > 1.Download Devcon.exe from Microsoft:
    >
    > http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe
    >
    > 2. Create a batch file with the following single line:
    >
    > devcon disable "pci\ven_8086&dev_27dc"
    >
    > (don't forget quotation marks).
    >
    > That's all.
    >
    > Enable with:
    > devcon enable "pci\ven_8086&dev_27dc"
    >
     
    Richard G. Harper, Apr 16, 2006
    #2
  3. The problem can be overcome by giving the command
    some intelligence, namely by specifying the network adapter's
    name, as it appears in the Control Panel (verbatim!) in this
    batch file:

    Device.bat
    =======
    @echo off
    goto Start
    ---------------------------------------------------
    Use this batch file to enable or disable a device
    from the Command Prompt.
    16.4.2006 FNL
    ---------------------------------------------------
    :Start
    setlocal enabledelayedexpansion
    set Adapter=Broadcom NetXtreme Fast Ethernet

    if /i "%1"=="enable" goto go
    if /i "%1"=="disable" goto go
    echo Syntax: Device enable / disable
    goto :eof

    :go
    set HWID=x
    set count=0
    set found=no

    devcon hwids "PCI\*" > device.txt
    for /F "tokens=*" %%* in (device.txt) do (
    set /a count=!count! + 1
    if /i "%%*"=="Name: %Adapter%" set found=yes& set count=1
    if !found!==yes if !count!==3 set HWID=%%*
    )
    if %found%==yes (
    echo HWID=!HWID!
    devcon %1 "!HWID!"
    ) else (
    echo Device "%Adapter%" not found.
    )
    endlocal
    del device.txt

    "Richard G. Harper" <> wrote in message
    news:%...
    > Unfortunately, this tip will only work for folks who have the same network
    > adapter that you do.
    >
    > --
    > Richard G. Harper [MVP Shell/User]
    > * PLEASE post all messages and replies in the newsgroups
    > * for the benefit of all. Private mail is usually not replied to.
    > * My website, such as it is ... http://rgharper.mvps.org/
    > * HELP us help YOU ... http://www.dts-l.org/goodpost.htm
    >
    >
    > <> wrote in message
    > news:...
    > > 1.Download Devcon.exe from Microsoft:
    > >
    > >

    http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe
    > >
    > > 2. Create a batch file with the following single line:
    > >
    > > devcon disable "pci\ven_8086&dev_27dc"
    > >
    > > (don't forget quotation marks).
    > >
    > > That's all.
    > >
    > > Enable with:
    > > devcon enable "pci\ven_8086&dev_27dc"
    > >

    >
    >
     
    Pegasus \(MVP\), Apr 16, 2006
    #3
  4. You could give it even more intelligence by using WMI calls to enumerate the
    various network adapters present and tossing out the known entries that
    aren't physical connections - but by that time I can right-click the network
    status icon I put down by the clock and disable and re-enable it. :)

    --
    Richard G. Harper [MVP Shell/User]
    * PLEASE post all messages and replies in the newsgroups
    * for the benefit of all. Private mail is usually not replied to.
    * My website, such as it is ... http://rgharper.mvps.org/
    * HELP us help YOU ... http://www.dts-l.org/goodpost.htm


    "Pegasus (MVP)" <> wrote in message
    news:...
    > The problem can be overcome by giving the command
    > some intelligence, namely by specifying the network adapter's
    > name, as it appears in the Control Panel (verbatim!) in this
    > batch file:
     
    Richard G. Harper, Apr 16, 2006
    #4
  5. 4C0010524026

    Joined:
    Jul 22, 2008
    Messages:
    1
    Likes Received:
    0
    download devcon form Microsoft

    1. Find the registry key for your adapter [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\
    2. Find the ID of your network adapter
    example: devcon hwids PCI\VEN*

    then find at this simple script your answer [​IMG]

    @echo off
    set ip=182.31.24.21
    set mac=4C0010524026
    set interface=Local Area Network
    set mask=255.255.255.0
    set gateway=182.31.24.1
    set dns1=212.221.112.2
    rem ======================
    set metric=0
    set mac_reg=[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0002]
    devcon disable PCI\VEN_10EC
    echo Windows Registry Editor Version 5.00 > tmp%interface%.reg
    echo %mac_reg% >> tmp%interface%.reg
    echo "networkaddress"="%mac%" >> tmp%interface%.reg
    regedit /s tmp%interface%.reg
    del tmp%interface%.reg
    netsh interface ip set address name=%interface% static %ip% %mask% %gateway% %metric%
    netsh interface ip set dns name=%interface% static %dns1%
    devcon enable PCI\VEN_10EC
     
    4C0010524026, Jul 22, 2008
    #5

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert L [MS-MVP]

    Re: enable/disable LAN from command line

    Robert L [MS-MVP], Jul 3, 2003, in forum: Microsoft Windows 2000 Networking
    Replies:
    1
    Views:
    7,443
    Usman
    Jul 4, 2003
  2. Jason Short

    Re: enable/disable LAN from command line

    Jason Short, Jul 3, 2003, in forum: Microsoft Windows 2000 Networking
    Replies:
    0
    Views:
    812
    Jason Short
    Jul 3, 2003
  3. polilop

    disable lan through command prompt

    polilop, Dec 16, 2004, in forum: Microsoft Windows 2000 Networking
    Replies:
    4
    Views:
    936
    Jetro
    Dec 17, 2004
  4. Replies:
    2
    Views:
    677
    Guest
    Nov 4, 2005
  5. raylopez99

    Simple questions for simple 2 PC file sharing network. Simple?

    raylopez99, Feb 10, 2007, in forum: Microsoft Windows 2000 Networking
    Replies:
    3
    Views:
    776
Loading...

Share This Page