Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9217

List all the serial ports (available and busy) on any of windows terminals

$
0
0

The cmd's mode command shows all the available (to be opened) serial ports, omitting the ones which are occupied by other programs. The PowerShell's command:

[System.IO.Ports.SerialPort]::getportnames()

shows all the existing ports even if they have been opened by other software. However, it doesn't show the ports which have been opened internally by PS itself. For example, if I define a new port object by:

$port= new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one

the mode command does not list 'COM3', indicating that the port is actually open in another program (i.e., PS). But the first PS command above still shows it as available. Somehow PS already opens the port when the object is defined but still lists them as available! Now if I open the port in PS:

$port.Open()

PS doesn't list it anymore.

What I want is to have a cmd or PS command to list all the serial ports regardless of they are being opened in a program or not.


Viewing all articles
Browse latest Browse all 9217

Trending Articles