How do I clean up COM ports in use?
Solution 1:
Run Device Manager from elevated command line:
> set DEVMGR_SHOW_NONPRESENT_DEVICES=1
> devmgmt.msc
Enable "Show hidden devices" in the menu, and uninstall grayed-out COM ports.
Solution 2:
I found a useful answer at How to clear or Reset COM port ?
- Click start → Run → type
regedit
and click OK button - Navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter
- Now on the right panel, you can see the key
ComDB
. Right-click it and click modify - In value Data section select all and delete reset to zero (
0
)
Its 32 bytes with 8 bits in each byte in hexadecimal representation. A bit of value 1 makes a port number (1...256) reserved. The first 8 ports are in two leftmost hexadecimal values, bits ascending from lowest to highest right to left, the next 8 ports are in the second two and so on: hexF3 24
would be binary1111 0011 0010 0100
, which means that following ports are used:1, 2, 5, 6, 7, 8
(1111 0011)
and11, 14
(0010 0100)
. - Close the registry editor and then restart your computer. If you set the value to
0
all COM ports are free.
You may need to reinstall any USB-to-serial converter.
Solution 3:
Thanks for all the advice above. I wrote software to automatically clean up the Registry but though it did adjust the Hardware, Software, and Arbiter sections it did NOT remove the phantom COM port entries. Even a reboot with the "USB to 2Serial Port" device removed did not clean up the system properly.
However, the instructions on this PDF did work correctly:
For Win7, I adjusted the instructions slightly on that PDF to be:
- click Start / (right click:) Computer / Properties / Advanced System Settings (not Device Manager)
- Click Environment Variables
- Click in the System variables (bottom section) click New
- Enter Variable Name: DEVMGR_SHOW_NONPRESENT_DEVICES
Enter Variable Value: 1 - Click OK (exits Environment)
Click OK (exits System Properties)
Click Start. In the command box, type Manage This shows the Computer Management window ...
- Click Device Manager
- Click View and select Show Hidden Devices
- Click Ports (COM & LPT)
Now all the ports, real (black text) and phantom (grayed out text) appear. - One by one, right click the phantom ports, and select Uninstall
This should now have cleared out your system of unwanted phantom USB ports.
Note: after cleaning out all my phantom ports, leaving only "COM1", I find my Registry shows:
Hardware: COM1
Software: COM1, COM2, COM3, COM4, COM5
Arbiter: COM1, COM2, COM3
And a right click on Computer / Properties / Device Manager / Ports shows only COM1. Right click on COM1 / Properties / Port Settings / Advanced shows COM1 with COM2 "in use" and COM3 "in use". All the other settings up to 7 that used to be "in use" are now freed up. So only the "Arbiter" setting seems to be telling the Win7 system what is really "in use". The Computer Management system has cleaned up the Arbiter, but not cleaned up the Software section...
... many are the mysteries of Microsoft...
Solution 4:
Resolving USB driver issues
Method Using Elevated Command Prompt
ie type cmd in search bar then right click cmd.exe selecting Run as Administrator
• 1st stage As discussed from command prompt type; set devmgr_show_non_present_devices=1 devmgmt.msc
Under Ports (Com & LPT) delete all instances of prolific USB to Serial Comm Port
• 2nd Stage Again from Elevated Command Prompt - Remove Driver Packages from drivers store. The driver store is a protected area of the computer that contains device driver packages that have been approved for installation on the computer
You need to Identify OEM#.inf where # is a number so type
pnputil.exe -e (then enter)
Read the entries in the output to find the description of your package(s) and its file name(s)
Its highly likely you will have multiple entries from previous attempts.
Note all oem###.inf instances of the prolific driver where # (hash) is the number.
To remove entries type:
pnputil.exe -d oem###.inf
(use space between exe & - and d & Oem then press enter) Remember to replace # with the number of the inf file you want to delete.
If the computer reports that the driver package is in use by a currently installed device, then you must either uninstall the device first, or use the -f on the pnputil command to force deletion of the package.
Also you may have driver package loaded on as program that may need removal using control panel/programs/uninstall a program.
If you do all that before loading the correct driver package and try to keep the Com device inserted in the same port rather than moving it around your ports you will have fewer problems with the Prolific driver.
Solution 5:
I have a simple solution that worked for me... my count was up to 45 com ports in use!
1) Open Device Manager
2) From the View menu, select 'Show Hidden Devices'
3) Expand 'Ports (COM & LPT)' category from the list
4) Right-click on all the devices and remove them (no need to tick to delete the driver)
5) From the Action menu, select 'Scan for New Devices'
6) Viola! All the actual devices will be re-allocated from COM1