Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / How to Clean Up or Reset COM Port Numbers in Windows

June 8, 2023 PowerShellWindows 10Windows 11Windows 7Windows Server 2019

How to Clean Up or Reset COM Port Numbers in Windows

When you connect a new COM device or a USB device to your computer (USB modem, mobile phone, Bluetooth adapter, serial to USB converters, etc.), Windows detects it using Plug-n-Play and assigns it a COM port number in the range of 1 to 255 (COM1, COM2, COM3, etc.). If this device is connected again, the reserved COM (Communication, or Serial) port number is assigned to it. A new device gets the first free COM port number. It often happens that when connected, external devices create several COM ports at once. In my case after connecting a Bluetooth adapter 10!!! new COM ports have appeared in the system.

A number of legacy applications are able to address only two-digit COM port numbers, and won’t work with COM100 and higher. In the worst cases, these programs work only with COM1-COM9 ports. What if a device has got a higher COM port number?  Is it possible to reset the numbering for reserved COM ports and delete assigned ports?

Contents:
  • How to Change a COM Port Number for a Device in Windows?
  • Find Out Which Process is Using a Serial COM Port in Windows
  • Resetting COM Port Numbers in Windows Registry

How to Change a COM Port Number for a Device in Windows?

In Windows, you can manually change the COM port number assigned to a device. Suppose the necessary COM port is already busy, and you want to try to free it.

  1. Open the Device Manager by running the devmgmt.msc command;
  2. Select View->Show Hidden Devices in the menu;Show Hidden Devices
  3. Then expand Ports (COM & LPT) and find your device in the list;
  4. Go to the Port Settings tab and click the Advanced button;
  5. The current COM port number assigned to the device can be found in the COM Port Number field;
  6. To change it, open the drop-down list and select the COM port number you want to set.Change COM port assigment

But more often you cannot change the assigned COM port number to another one in the hardware properties, since all the “lower” COM ports are already in use.In this case, you need to try to remove the COM port reservation

  1. Expand the Ports (COM & LPT) branch, find which COM port number you need is assigned to (a pale icon means that this COM port is assigned, but this device is not currently connected);
  2. Right-click it and select Uninstall;Uninstall COM device
  3. Now you can assign the freed COM port to another device. Once again open the properties of your device, go to the Port Settings -> Advanced tab. Then go to the Port Settings tab and click Advanced. Select the free COM port in the dropdown list.com port number

However, this method does not allow you to free the busy COM port in all cases.

You can get the full list of busy COM ports on Windows using PowerShell:

Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description
You can get the COM port number for a specific device by its name, for example:

Get-WMIObject Win32_SerialPort | Where-Object { $_.Name -like "*Arduino*"}|select name, deviceid
or
Get-WMIObject Win32_SerialPort | Where-Object { $_.Name -like "*GPS*"}|select name, deviceid

Find Out Which Process is Using a Serial COM Port in Windows

You won’t be able to release the COM port of a device that is used by Windows or a running program (process). First, you need to stop the process that is currently using the COM port. You can use the Process Explorer tool (by Sysinternals) to find out the name of the process using a particular COM port number (https://docs.microsoft.com/en-gb/sysinternals/downloads/process-explorer).

First, you need to display the name of the service that uses the COM port. Run the PowerShell command:

get-pnpdevice -class Ports -ea 0| Select Name, PNPDeviceID, Status, Service

powershell - get com port service name

The service name of the specific COM port is shown in the Service column. For example, for COM2 it is Serial. Now you need to run Process Explorer as an administrator and select Find -> Find Handle or DLL from the menu. In the Handle or DLL substring line, enter the Service value obtained earlier. In our example, this is Serial .

Process Explorer should show the process name that is currently using your COM port. To release the COM port, kill the process or program.

process explorer - getting process name is using serial com port number

Resetting COM Port Numbers in Windows Registry

Information about the COM ports in use is stored in CommDB registry parameter under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter reg key.

  1. Open the Registry Editor (regedit.exe) and go to the registry key mentioned above;COM Name Arbiter
    Important! We strongly recommend you to backup this registry key (File -> Export) before doing anything. If something goes wrong, you can restore the original COM port configuration.
  2. The value of ComDB parameter in the binary format determines the list of COM ports reserved in Windows. Each bit determines the state of the corresponding port (from 1 to 255). For example, if you need to leave the reservation only for COM3, the hex value of ComDB will be equal to 04 (0000 0100);  ComDB
    Important! Be very attentive, and don’t add any additional bits to the parameter, or the system will start to fail into a BSOD.
  3. If you have to reset all COM port bindings, change the value of ComDB to 0;reset com port
    Note. You can see the complete list of COM ports connected in Windows under the registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM. The registry entries under the SERIALCOMM can only be present only when underlying devices are connected and ready. This subkey is part of the HARDWARE key, and it is recreated each time the system starts.SERIALCOMM
  4. The HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports registry key contains the list of all assigned COM port numbers. You can remove all unnecessary port reservations. In our example, we’ll leave only COM3 and delete the rest ports;used com ports
  5. Unplug all external devices and restart your computer;
  6. After the reboot, connect the devices in the necessary order, reinstall USB-to-serial converters, etc. All detected COM port devices will be automatically detected by the system and assigned sequential COM port numbers.

You can also use the following free tools to clean up reserved COM ports:

  • COM Name Arbiter Tool – this tool can help you to reset COM port reservations and find the used COM port numbers. Download the tool and run it as an administrator.  Select the COM ports you want to release and click Clear unused Reservations and Remove non-present devices;com name arbiter reset tool to reset com port number assignment
  • Device Cleanup Tool – the utility is used to search the registry for previously connected devices (under the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum), remove unused devices, and clear COM port reservations.

4 comments
2
Facebook Twitter Google + Pinterest
previous post
Mailbox Size and Quotas in Exchange 2019/2016 and Microsoft 365
next post
Can’t Access Shared Folders or Map Network Drives from Windows 10 and 11

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

4 comments

Mahmood February 11, 2018 - 8:04 am

Hi dear
When I open Device Manager there is no branch of (COM & LPT) to expand. How can I Add or Find it?

Reply
mahdi August 26, 2018 - 11:36 am

thank you so much

Reply
zack January 24, 2020 - 6:16 am

thanks you so much , life saving post 🙂 , i mostly work with iot devices and sometime com ports get busy and am getting com port busy returns in code so this saved my life in flushing com port

Reply
SYAM BHUPATHI October 30, 2021 - 1:53 pm

Thank you for the post, very helpful

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top