serial-portvirtual-serial-port

Change COM port via registry, command line or software?


Does anybody know how to change the COM port number that Windows maps to a USB virtual COM port? You can change this via the Device Manager and clicking on the Advanced button.. but how can you do this via an API, registry change or command line operation?

Any ideas please?


Solution

  • You might find this answer useful:

    How do I get the friendly name of a COM port in Windows?

    It's about finding the friendly name, but I think you'll find it points you towards the right area of the registry, using the 'official' mechanism for locating the right key.

    However, if you change the port assignment, you should also update the com port database - see: https://msdn.microsoft.com/en-us/library/ff546481.aspx

    When I had to do something similar, I found the right device using the mechanism described in the linked SO article, and then called SerialDisplayAdvancedSettings((HWND)NULL, hDeviceInfo, &devInfoData); to display the advanced dialog and let the OS handle the hard work.

    Nowadays you're more and more likely to be encountering odd 'not real' serial ports (e.g. USB ports) which might have other incompatibilities you need to be wary of too.