Disabling ethernet connection with command line? [

2019-03-21 13:19发布

问题:

I have seen many 'disable wireless with command line' posts, but not about disabling ethernet.

Is it possible to do so (on Windows 7, 32 & 64 bit)?

回答1:

In Windows 7, you can use

wmic path win32_networkadapter where NetConnectionID="Local Area Connection" call disable
wmic path win32_networkadapter where NetConnectionID="Local Area Connection" call enable

Even in more details ( Start elevated Command Prompt ):

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 the command in Windows XP:

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

If the network name is not "Local Area Connection", substitute with the one you're using.

Reference: http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/enabledisable-network-interface-via-command-line/17a21634-c5dd-4038-bc0a-d739209f5081



回答2:

To temporarily disable it you could use this:

ipconfig /release local*3

if your connection was called "Local Area Connection 3"



回答3:

if you want to disable network automatically on shutdown for windows 7 64bit

use notepad type the disable command line from Raptor's answer above and save it as a .bat file

Run gpedit.msc and go to...computer configuration,windows settings,scripts,shutdown

double click on "shutdown", click on "show files", paste the .bat file in the popup folder. click on add to add the .bat file.

:)