delete or reset by default multiple Local Area Connection

In some scenarios, we connect several network cards to our PC. For each network card, Windows creates a new local area connection, which is identified as: "Local Area Connection X", Where "X" is the number assigned by windows to this new connection. Windows incrementally assigns this number to new network cards. Regardless of whether the network cards previously connected, exist or not. This can be verified with the following commands:

wmic nic get name, index
wmic nic where "netconnectionid like '%'" get netconnectionid
FOR /F "tokens=*" %i IN ('NetSh.exe Interface IP Show Interface') DO echo %i
wmic nic where "NetConnectionStatus=2" get NetConnectionID |more +1

Possible regedit path:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\

How can I clean all previous network connections, and "Local Area Connection X" that no longer exist, and reset network cards by default.

I prefer to do it with batch (devcon, wmic, etc. Not gui)

thanks

PD: About "netsh interface set interface "Local Area Connection" DISABLED" This answer is not enough


You need to remove them from device manager. I usually do it from command line and part GUI. However, I've mentioned a tool below that can be scripted.

From an administrative command prompt type:

set devmgr_show_nonpresent_devices=1
start devmgmt.msc

When device manager opens, set the option to show hidden devices. Now, you can expand the network adapters section and delete all ghosted (greyed out) devices. You'll see all those previous network adapters in there.

I often clean all the ghosted devices to solve different issues. It is much more efficient to use the tool: Ghostbuster

It can quickly clean out all ghosted devices on your computer. If you look at the documentation, under advanced options, you can see how to run this from the command line or in a script.