# Windows – Change COM Port Number programmatically

com portserial portwindows

In Device Manager, I can right click on a serial device, navigate to the Port Settings tab, click Advanced, and change the COM Port Number via a drop-down menu.

I need to automate this step across a large number of PCs. Is there a way to script this process, or to do it programmatically?

If you're referencing some application that someone else wrote, and you're just stuck with someone else's program design (or lack thereof), then you may want to consider adding a batch script to modify the registry key under HKLM\Hardware\DEVICEMAP\SERIALCOMM at startup, since the new value(s) are not likely to hold between re-boots.