top of page

Comet USB AutoFind - now obsolete

As the CTI Comet USB no longer works with fixed COM ports, some users may find it harder to setup their software with the correct COM port. To aid developers in making it easier for their customers, we have developed the following code which we will provide under the terms of the licence specified below. This means that you are free to use the code or binary as you wish however we will provide NO support for it in any way!


The code is reasonably simple, it queries the computer for all CTI Comet USB devices and returns the result as a string. There are two different ways this could be used.

  1. If your software uses VB.NET you could incorporate the code into your solution.

  2. Use the included executable and call from within your software parsing the result.

When the code/program is executed, it will print the COM ports of all the CTI Comet USB devices connected to the computer.

The code requires the .NET framework v4 (or later) to satisfy the System.Management import.

Files you can download are below:

Below is the code used in the software that was written using Microsoft Visual Studio Express, remember to include the licence if you copy this code. And dont forget to add System.Management under project references for the .NET project.

This code has been tested on Windows Vista and 7.

  1. Imports System.Management


  3. Module MainModule


  5.     Sub Main()


  7.         ' Create the dictionary to hold all COMETS.

  8.        Dim result As New Dictionary(Of String, String)


  10.         ' Search for all COMET devices.

  11.        result = findCOM()


  13.         ' Output the result to the console.

  14.        Dim i As Integer

  15.         Dim str As String

  16.         str = ""

  17.         i = 0

  18.         For Each foundPort As KeyValuePair(Of String, String) In result

  19.             If Not (i = 0) Then

  20.                 str += ";"

  21.             End If

  22.             str += "COM" + foundPort.Key

  23.             i = i + 1

  24.         Next

  25.         System.Console.Write(str)


  27.     End Sub


  29.     ' Returns a list of COM port numbers for all attached CTI Comet USB devices.

  30.    ' Formatted with a ; between each device.

  31.    Private Function findCOM()

  32.         Dim identPnpPorts As New Dictionary(Of String, String)

  33.         Dim returnSerials As New Dictionary(Of String, String)

  34.         Dim portNameData As String

  35.         Dim comPortNumber As String


  37.         Try

  38.             Dim portSearcher As New ManagementObjectSearcher("\root\CIMV2", "Select Name from Win32_PnPEntity")

  39.             For Each port As System.Management.ManagementObject In portSearcher.Get()


  41.                 'search all of the PNP entries for the device

  42.                If port("Name").ToString.ToUpper.Contains("(COM") Then

  43.                     portNameData = port("Name").ToString

  44.                     comPortNumber = port("Name").ToString.Substring(port("Name").ToString.IndexOf("(COM") + 4)

  45.                     comPortNumber = comPortNumber.TrimEnd(")"c)

  46.                     identPnpPorts.Add(comPortNumber, portNameData)

  47.                 End If

  48.             Next

  49.         Catch ex As Exception

  50.             'Need to handle possible errors

  51.        End Try


  53.         For Each foundPort As KeyValuePair(Of String, String) In identPnpPorts

  54.             If (foundPort.Value.Contains("CTI Comet USB COM Port")) Then

  55.                 returnSerials.Add(foundPort.Key, foundPort.Value)

  56.             End If

  57.         Next


  59.         Return returnSerials


  61.     End Function

  62. End Module

bottom of page