We have a computer that's used to test some devices. Every once in a while, testers need to go in and remove the assigned COM ports so they free up and start back at 1. Lately, it's been assigning them the same COM port to a couple of devices (around 8 are connected at the same time) and also, they need to change the test code to match whatever number was assigned by the OS.
Duplicate numbers was the reported problem, but I see the 'having to check the COM ports and updating the code' multiple times a day as a problem too.
In Device Manager, if I turn on to show hidden devices, I see hundreds of them!
You can tell by the size of the scrollbar the list is pretty big. I can click at each one and uninstall, but that's insane going 1 by 1 which is why I ask for a command-line alternative, so I can write a script that they can double click when they need to reset the ports.
Of course, if there's some software out there that will allow for this to happen then that's good too.
Best Answer
Remove active USB ports:
Remove active LPT and COM ports:
Query all COM and LPT ports:
Query active USB ports:
Query all USB ports - different results:
Enum all devices:
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!
Example:
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
...