Welcome DeMott, Dawson D,
Windows does not normally assign a COM port based on a "service" priority. Instead, COM port assignment is primarily handled by Plug and Play (PnP) and the device's driver when the device is detected.
A few key points:
- When a serial device is connected, Windows identifies it using its hardware ID, instance ID, and driver information.
- Windows then assigns or reuses a COM port number associated with that device. If Windows recognizes the device as one that was previously connected, it will typically reuse the same COM port number.
- Historically, Windows reserved COM port numbers in the COM Name Arbiter database and assigned available numbers as new devices appeared.
- The application or service itself usually does not determine which COM port it receives. Instead, software must open the COM port already assigned by Windows to the device. Multiple applications generally cannot exclusively open the same serial port at the same time.
If your question is specifically about multiple serial devices being connected simultaneously, or about which driver/device gets COM3 versus COM4, please let us know the scenario and the device type (USB-to-Serial adapter, Bluetooth serial port, built-in UART, etc.), and I can provide a more detailed explanation.
Microsoft documentation:
- Device Manager and COM port configuration: Windows Hardware Developer Documentation - Windows drivers | Microsoft Learn
- USB Serial Driver (Usbser.sys): USB Serial Driver (Usbser.sys) - Windows drivers | Microsoft Learn
I hope this helps clarify how Windows handles COM port assignment.