Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I'm not familiar with creating .bat files, but I want to create a file to deactivate/disable a network device

enter image description here

This is in win7. I have googled some similar problems, but nothing to solve this. pls help.

share|improve this question

marked as duplicate by Oliver Salzburg Oct 15 '13 at 12:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

deactivate/disable a network connection or the actual device? What exactly is the model of that device? A modem? Router? WIFI? IF its just a network connection on a windows 7 computer then check here >… or here… – Logman Oct 14 '13 at 23:50
I think that device is a speedtouch router/modem. What are trying to disable? Is it the device or is it just the visibilty in windows? You might be able to write a .bat that connects through telnet or SSH to shutdown your router but that is beyond my expertise. – suit Oct 15 '13 at 1:02

Perhaps you might be able use this in a batch file.
I'm unsure if your router will show up though.

Get NIC list and index number:

wmic nic get name, index

Enable NIC with index number: (eg: 7)

wmic path win32_networkadapter where index=7 call enable

Disable NIC with index number: (eg: 7)

wmic path win32_networkadapter where index=7 call disable

Here is a batch file provided on the above link (You may be able to change it to suit your application).

@echo off
goto Choices

REM use this command to determine what the adapter index number is
REM wmic nic get name, index

choice /c:123456
If ERRORLEVEL == 6 goto Enable_Wireless_Disable_LAN
If ERRORLEVEL == 5 goto Enable_LAN_Disable_Wireless
If ERRORLEVEL == 4 goto Disable_Wireless
If ERRORLEVEL == 3 goto Disable_LAN
If ERRORLEVEL == 2 goto Enable_Wireless
If ERRORLEVEL == 1 goto Enable_LAN
goto EOF

wmic path win32_networkadapter where index=9 call enable
goto :EOF

wmic path win32_networkadapter where index=7 call enable
goto :EOF

wmic path win32_networkadapter where index=9 call disable
goto :EOF

wmic path win32_networkadapter where index=7 call disable
goto :EOF

wmic path win32_networkadapter where index=9 call enable
goto :4

wmic path win32_networkadapter where index=7 call enable
goto :3

echo 1 Enable LAN
echo 2 Enable Wireless
echo 3 Disable LAN
echo 4 Disable Wireless
echo 5 Enable LAN / Disable Wireless
echo 6 Enable Wireless / Disable LAN
goto Top


share|improve this answer

Enabling or disabling a network device in the Network Devices list is identical to enabling or disabling it in the Device Manager. You can use the Microsoft tool devcon to do this from the command-line.

  1. Download the file, extract it, and put it somewhere (we’ll use c:\tools for the example below).

  2. Now you need to determine the device ID. You can do it in two ways:

    • With the Device Manager

      1. Open the Device Manager (devmgmt.msc)
      2. Expand the Network adapters branch
      3. Locate and select the device
      4. Open its Properties dialog (double-click or [Alt+]Enter or right-click→Properties or Action→​Properties)
      5. Switch to the Details tab
      6. Select the Matching Device Id field
      7. Copy the ID (e.g., PCI\VEN_1337&DEV_2600&SUBSYS_DEADCAFE)

    • With devcon

      1. Open a command-prompt
      2. Run this command:

        devcon findall * | find /i "speedtouch" > "%temp%\devcon.txt"
      3. Open the file %temp%\devcon.txt and find your device

        • If you don’t find your device, try leaving out the filter:

          devcon findall * > "%temp%\devcon.txt"`
      4. Copy the ID (you only need up until the end of the SUBSYS field)

  3. Test it (replace the path and ID with your own, and make sure to put the ID in quotes):

    devcon disable "PCI\VEN_1337&DEV_2600&SUBSYS_DEADCAFE"
  4. Copy it to a batch-file (make sure to include the path if you are storing the batch-file somewhere different than devcon.exe). For example:

    c:\tools\devcon disable "PCI\VEN_1337&DEV_2600&SUBSYS_DEADCAFE"

You can then create a shortcut to the batch-file and set it to run minimized. If you don’t need to run other commands (the batch-file only contains the single line), then you can make a shortcut to run the command directly and forgo the batch-file altogether.

You can also make a batch-file/shortcut to enable the device as well (writing one to toggle the device is a little more complicated). You can even use this to enable or disable other devices (years ago I wrote one to toggle my old gameport gamepad when running DOSBox to work around a bug).

Screenshot of NIC device ID from Device Manager

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .