List all the serial ports (available and busy) on any of windows terminals
Try this :
- Click on a start menu
- Go to "run"
- in the field type CMD
- execute this commands in this order: a) C:>powershell b) PS> Get-WMIObject Win32_SerialPort
If you are x64 so type win64.
It should work i guess.
Related videos on Youtube
Foad
Updated on September 18, 2022Comments
-
Foad over 1 year
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.-
spikey_richie about 5 yearssuperuser.com/questions/835848/… - 8 In the command prompt use: C:\>wmic path Win32_SerialPort OR In PowerShell: PS> Get-WMIObject Win32_SerialPort OR PS> Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description Hope this helps.
-
Foad about 5 years@spikey_richie
cmd
'swmic
andchgport
or PS'sGet-WMIObject
are the options. thanks a lot.
-
-
Stef about 5 yearsor try this -> C:\>wmic path Win32_SerialPort
-
Foad about 5 yearsthe first comment on the original post points towards a another post with a lot of nice solutions including the ones you just mentioned. Thanks.
-
Stef about 5 yearsYou are welcome. Have a nice time