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

11,400

Try this :

  1. Click on a start menu
  2. Go to "run"
  3. in the field type CMD
  4. 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.

Share:
11,400

Related videos on Youtube

Foad
Author by

Foad

Updated on September 18, 2022

Comments

  • Foad
    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
      spikey_richie about 5 years
      superuser.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
      Foad about 5 years
      @spikey_richie cmd's wmic and chgport or PS's Get-WMIObject are the options. thanks a lot.
  • Stef
    Stef about 5 years
    or try this -> C:\>wmic path Win32_SerialPort
  • Foad
    Foad about 5 years
    the 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
    Stef about 5 years
    You are welcome. Have a nice time