Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

Enter image description here

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.

share|improve this question
up vote 5 down vote accepted

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!



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:|


If ports enumerate devcon status @usb\* - delete this registry key:|



Open registry

Change permission

Delete key

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 ...

share|improve this answer
that place you suggested in the registry does look like the place, but devcon seems more straight forward, I do see a long list of devices with devcon, but when i try the remove command i get 'Remove Failed' on all – geermc4 Feb 7 '13 at 0:29
@geermc4 port enumerate devcon FindAll =Ports or devcon status @usb\* ? – STTR Feb 7 '13 at 0:32
those did work, just remove failed, I was trying with the old version link since it is a single smaller file to download, but now trying with the new version and that is working yay! – geermc4 Feb 7 '13 at 0:43
@geermc4 Thx at good comment! Good Luck! – STTR Feb 7 '13 at 1:33
thank you, you now have 1 happy tester group – geermc4 Feb 7 '13 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .