question

AKR2021-3344 avatar image
0 Votes"
AKR2021-3344 asked Castorix31 answered

Switching COM Ports using script or Powershell or command line

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-10-setupoffice-scripts-excel-devwindows-10-application-compatibility
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered

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




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.