How can I remove all COM ports from the command line on Windows 7?
Solution 1:
Remove active USB ports:
devcon /r remove @usb\*
Remove active LPT and COM ports:
devcon /r remove =ports
Query all COM and LPT ports:
devcon FindAll =Ports
Query active USB ports:
devcon status @usb\*
Query all USB ports - different results:
devcon findall @usb\*
devcon findall =USB
Enum all devices:
devcon hwids * > hwids.txt
Part at WDK, Windows Driver Kit Version 7.1.0.
The old version, 2003-01-29, does not work on Windows 7 (not del device). devcon old version 2003-01-29
Source code for DevCon
Alternative 1 - PnPUtil
Alternative 2 - registry key, search USB device at subkey
Not del all!
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI
Example:
reg delete "HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR\Disk&Ven_Seagate&Prod_USB_2.0_Cable&Rev_0148" /f
If ports enumerate devcon FindAll =Ports
- delete this registry key:|
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI
If ports enumerate devcon status @usb\*
- delete this registry key:|
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB
Example:
Thx geermc4! I tested devcon. On Windows Driver Kit Version it works correctly with Windows 7.
The hardware profile can be set up only for Windows XP. We will not be able to setup on Windows 7. It is by design ... backup HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
...