Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to change COM port number

I need to write a program in VB6 to list all of the available COM ports on a
computer and allow the operator to change the COM port number. I can get the list of available COM ports using the WMI but how to I change the COM port number?

I have to support a legacy program that looks for connections to devices on
specific com ports. Genius that this original programmer was, he hard coded
those com port numbers.

Currently we use a Digi edgeport with 4 serial ports. The Edgeport comes
with a utility that allows you to change the COM port numbers. However we
would like to move to single USB to serial devices (serialized of course),
which do not provide the same type of utility. I would like to write a VB6
program to help with setup by allowing the user to connect a terminator to a
serial port, send a message out to each available com port, and look for the
response. Once the user identifies the serial port I want to allow them to
change the com port number to one of the hard coded ports.

Of course they could use the device manager to change the com port numbers but I wanted to make an automated, easy to use utility, since the users will not be computer savy.

Any ideas?

Thanks,
quantum1976
[1291 byte] By [quantum1976] at [2007-11-11 8:00:55]
# 1 Re: How to change COM port number
I have done this by changing settings in the registry, but it is tricky trying to do it on any just any computer. You have to find the entries for the specific controller and rename the port. The problem is that different controllers use different schemes for naming the ports. If you search the registry for a port name such as 'COM3' on a couple of different computers, you will see what I mean.
I have control over the computers used within my company, so I can write code to perform this function. However, if you do not know which controller is used on all of the computers you need to access, then it is going to be difficult.
There is also a COM port redirector utility that I saw at www.freedownloads.com which allows you redirect streams from one com port to any other.
dkroger at 2007-11-11 17:26:10 >