Switching COM Ports using script or Powershell or command line

AKR2021 1 Reputation point
2021-08-17T16:24:20.807+00:00

Hello,

I am working on OEM. I use a windows image to install the devices. When the device is newly installed , the COM ports are shifted to 9-16 rather than 1-8 and it shows as comports 1-8 are in use. Is there a possibility to write a script to change the COM Port numbers. I was changing them manually till now but manual changes is not an option any more.

Thank you

Windows for business Windows Client for IT Pros Devices and deployment Set up, install, or upgrade
Microsoft 365 and Office Development Other
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,521 Reputation points
    2021-08-18T10:57:54.033+00:00

    It can be done in C++, but it is complex, because there are several steps :
    DefineDosDevice
    Writing to
    HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM with RegSetValueEx
    ComDBReleasePort
    ComDBClaimPort
    SetupDiSetDeviceRegistryProperty with SPDRP_FRIENDLYNAME
    SetupDiSetDeviceInstallParams with DI_PROPERTIES_CHANGE

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.