How to find COM port of connected IoT device on Windows

When you need to talk to an IoT device over RS232 connected to the computer via USB cable, the first thing that you need to know is the name of the port. Windows assigns port numbers like COM3, COM7, COM21 to connected devices. How to find the number?
The quick way is to type the following command:

The quick way is to type following command:

chgport

The output:

COM10 = \Device\VCP1
COM9 = \Device\VCP0

For older versions of Windows you can use:

mode

The output:

Status for device COM9:
-----------------------
    Baud:            1200
    Parity:          None
    Data Bits:       7
    Stop Bits:       1
    Timeout:         OFF
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     ON
    RTS circuit:     ON

You can find all these hints also on SuperUser.

But what to do when the device is connected and the list of COM ports is empty?

The most common reason is that Windows is missing one of the following drivers:

Steps to resolve the problem:

The system should pick the installed driver and assign it to the device.

You can use also idf-env tool to install the drivers by following PowerShell commands:

Invoke-WebRequest 'https://dl.espressif.com/dl/idf-env/idf-env.exe' -OutFile .\idf-env.exe
.\idf-env.exe driver install --ftdi --silabs

Footnote: following PowerShell command might NOT list all connected IoT COM devices, but you can find it on many forums on the internet. Often it displays just COM3 and COM4 which are not associated with IoT device.

Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description