以编程方式更改COM端口号 [英] Programmatically changing a COM port number
问题描述
大家好,
我有一个USB到RS-232设备,可用于与各种设备进行通信.但是,每当我将其插入USB端口时,COM端口号就会从上次插入时改变,例如,昨天它注册为COM1,今天是COM8.
现在,我知道我可以进入设备管理器并手动进行更改了,但这很痛苦.我想编写一个可以运行的脚本,它将查找我的设备,获取为其分配的com端口号,并将其更改为所需的数字(例如,我一直希望它为COM1).
我之所以需要它,是因为我正在使用一个商业应用程序,该应用程序设置为仅使用该特定的COM端口.
那么,我从哪里开始呢?
谢谢,
Sean
Hello All,
I have a USB to RS-232 device which I use to communicate with various equipment. However, whenever I plug it into a USB port then COM port number changes from the last time I plugged it in, for example, yesterday it registered as COM1 and today it is COM8.
Now, I know I can go into the device manager and change it manually, but that is a pain. I would like to write a script that I can run and it will look for my device, get its assigned com port number and change it to the number I want (for example, I always want it to be COM1).
The reason I need this is because I am using a commercial application that is set to use only that particular com port.
So, where do I start?
Thanks,
Sean
推荐答案
好吧,第一条也是最好的建议是将您的商业应用程序"丢进去,并将开发此产品的公司列入黑名单:).好吧,除了笑话...
如果您负担不起这一步,则有一类名为"COM Port Redirector"的实用程序.它会成功的.参见:
http://en.lmgtfy.com/?q=com+port+redirector [ ^ ]
祝你好运!
—SA
Well, first and best advice would be to trash your "commercial application" and blacklist the company which develop this stuff :). Well, beyond the jokes...
If you cannot afford that step, there is a class of utilities called "COM Port Redirector"; it will do the trick. See:
http://en.lmgtfy.com/?q=com+port+redirector[^]
Good luck!
—SA
这篇关于以编程方式更改COM端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!