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.
Answer
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
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
...
No comments:
Post a Comment