How do I clean up COM ports in use?

382,487

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 ?

  1. Click start → Run → type regedit and click OK button
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter
  3. Now on the right panel, you can see the key ComDB. Right-click it and click modify
  4. 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: hex F3 24 would be binary 1111 0011 0010 0100, which means that following ports are used: 1, 2, 5, 6, 7, 8 (1111 0011) and 11, 14 (0010 0100). enter image description here
  5. 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:

  1. click Start / (right click:) Computer / Properties / Advanced System Settings (not Device Manager)
  2. Click Environment Variables
  3. Click in the System variables (bottom section) click New
  4. Enter Variable Name: DEVMGR_SHOW_NONPRESENT_DEVICES
    Enter Variable Value: 1
  5. Click OK (exits Environment)
  6. Click OK (exits System Properties)

  7. Click Start. In the command box, type Manage This shows the Computer Management window ...

  8. Click Device Manager
  9. Click View and select Show Hidden Devices
  10. Click Ports (COM & LPT)
    Now all the ports, real (black text) and phantom (grayed out text) appear.
  11. 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

Share:
382,487

Related videos on Youtube

user3660103
Author by

user3660103

I did my bachelors in electrical engineering specializing in computer networking, and finished master studies in digital communications. Currently doing medical software development. I'm also an amateur radio operator, callsign YU1NKA/DM1NKA.

Updated on September 18, 2022

Comments

  • user3660103
    user3660103 almost 2 years

    How do I clean-up these in-use COM ports? enter image description here

    The COM port numbers always seem to be taken up by something and although right now I only have 4 serial ports (3 over Bluetooth and one USB to RS-232), I have numerous COM ports set as in use. I'd like to clean that list up a bit.

    Also it seems to me that from time to time, one of the taken COM ports gets freed up and then one of the devices I use will take that number creating confusion, since I'll have to go and hunt its com number in device manager.

    UPDATE:

    Well I just cleaned up countless USB devices that once were connected to the computer using USBDeview and still the problem still remains.

  • user3660103
    user3660103 about 12 years
    The hidden serial ports don't seem the be the main cause of the issue. As expected, I found numerous instances of serial ports created by my USB to RS-232 adapter, but even when they are cleaned up, I still have 11 extra COM ports set as in use.
  • user1686
    user1686 about 12 years
    @AndrejaKo: Do you have any devices listed under "Modems"? They also take up 1 serial port each.
  • user3660103
    user3660103 about 12 years
    Yes, but there's just one modem there.
  • nixda
    nixda almost 11 years
    Welcome to superuser. I edited your answer and added some more details. Free feel to rollback your post if needed.
  • user3660103
    user3660103 almost 11 years
    Looks interesting! I'll try it out and report the results.
  • Bob Brunius
    Bob Brunius over 9 years
    No, I followed this exactly and it didn't remove any of them.
  • Ramhound
    Ramhound over 8 years
    This submission has far to many formatting errors for my taste. Feel free to spend some time formatting your submission and I will reverse my vote.
  • bas
    bas over 8 years
    surprised that this answer doesn't have upvotes, as it is the only answer that actually solved my problem on Win7
  • Jason S
    Jason S about 8 years
    voila not viola
  • user3660103
    user3660103 about 8 years
    Does this actually work for serial ports, on Windows 7? Also, you're supposed to summarize the link contents in your answer, instead of just providing the link, in case link rot happens.
  • kimliv
    kimliv almost 8 years
    @nixda isnt it 1,2,5,6,7,8,11,14?
  • nixda
    nixda almost 8 years
    @kimliv I did not insert that part of the answer. That was the editor after me :) So you have to ask him
  • kimliv
    kimliv almost 8 years
    @trapicki isn't it 1,2,5,6,7,8,11,14?
  • trapicki
    trapicki almost 8 years
    @kimliv, you are right. Corrected. (Was 1, 2, 5, 6, 7, 8, 10, 15)
  • user2070305
    user2070305 over 7 years
    This worked for me and confirm that step 5 "restart your computer" is required. I couldn't find any other way to force a re-read of the registry.
  • Tom Kuschel
    Tom Kuschel about 7 years
    This works, but setting the system variable as seen in answer @Michael Herman is IMHO better way and the view in the Device Manager "show hidden devices" works afterwards. I don't know why MS has disabled that system variable on my PC per default.
  • Ninga
    Ninga almost 7 years
    Wow I had loads of mapped unused ports. Although Ive never had any problem mapping to an 'in use' port, its nice housekeeping.
  • Trevor
    Trevor over 6 years
    This worked for me on Windows 7 64 bit Enterprise Edition from an elevated command prompt
  • guest
    guest about 6 years
    This has already been proposed in an existing upvoted answer.
  • guest
    guest about 6 years
    This has already been proposed in an existing upvoted answer.
  • Assimilater
    Assimilater about 6 years
    Restart wasn't required for me. But this is the only thing that worked. I had done the other steps for showing hidden devices but nothing showed up. Perhaps because I was having difficulties getting the driver to work
  • Assimilater
    Assimilater about 6 years
    PDF Broken link. Where in the registry is "Hardware, software arbiter"? Are there any other instructions that should be carried over but were lost to the PDF?
  • sdbbs
    sdbbs almost 5 years
    Link rot happened - linked page does not exist anymore
  • gbarry
    gbarry about 3 years
    (1) It's shorter. (2) "Don't need to delete the driver" is useful info. (3) May not always work, but being simple, it's easy to try first. (x) I only needed to free up one port to put it in range of the program that "only went to 24" :)