I'm looking for a robust way to list the available serial (COM) ports on a Windows machine. There's, but I would like something less.NET specific - I want to get the list of ports in a Python or a C program, without.NET.I currently know of two other approaches:.Reading the information in the HARDWAREDEVICEMAPSERIALCOMM registry key. This looks like a great option, but is it robust? I can't find a guarantee online or in MSDN that this registry cell indeed always holds the full list of available ports.Tryint to call CreateFile on COMN with N a number from 1 to something. This isn't good enough, because some COM ports aren't named COMN.

For example, some virtual COM ports created are named CSNA0, CSNB0, and so on, so I wouldn't rely on this method.Any other methods/ideas/experience to share?Edit: by the way, here's a simple Python implementation of reading the port names from registry: import winreg as winregimport itertoolsdef enumerateserialports:' Uses the Win32 registry to return a iterator of serial(COM) ports existing on this computer.' 'path = 'HARDWAREDEVICEMAPSERIALCOMM'try:key = winreg.OpenKey(winreg.HKEYLOCALMACHINE, path)except WindowsError:raise IterationErrorfor i in itertools.count:try:val = winreg.EnumValue(key, i)yield (str(val1), str(val0))except EnvironmentError:break.

Serial

I think WMI is the way to go since it's pretty easy to get going and it has minimal code. It saves you from having to dig inside the registry and gives you some guarantee that it will work for more general situations in the future.You can install everything needed with pip install pypiwin32 WMI and it works out-of-the-box.Code import wmiquery = 'SELECT.

C-span live coverage. Psinfo.exe provides the most complete information of all the suggestions given, and it can be run on any Windows PC from the command line directly from an elevated CMD prompt, without permanent downloading: live.sysinternals.comtoolspsinfo.exe -s %userprofile%Desktoppsinfo.txtYou will get a security prompt when you run this, and a EULA prompt the first time on a machine. A text file will be saved to the current desktop.The EULA can be automatically accepted like this: live.sysinternals.comtoolspsinfo.exe -s /accepteula %userprofile%Desktoppsinfo.txt.

Python Write To Serial Port Windows

FROM Win32PnPEntity WHERE Name LIKE '%(COM%)'coms = wmi.WMI.query(query)for com in coms:print(com.Name)Output Communications Port (COM1)mbed Serial Port (COM3)mbed Serial Port (COM5)My guess is that your serial port is some sort of Plug 'n Play so this should work fine. For some reason Win32SerialPort doesn't work for all ports.