I have been using this function for years. I want to loop through all the ComPorts on a computer and return the ComPort of any port having VID 401 and PID 6003. This has worked forever but today I found a serious problem. I guess there is a "PortName" and a "FriendlyName" for each port. I have been incorrectly using the "FriendlyName" and need to start using the "PortName" because I guess there are certain instances where the "FriendlyName" doesn't really reflect the ""PortName". Here is the code. Can anyone tell me what I have to change to get the "PortName" and not the "FriendlyName"?
AutoIt
; Will scan all FTDI COMPorts in the WMI and return either the comport FTDI on or "" Func FindOBD() Local $NumericPort, $Leftprens, $Rightprens, $TestDevice Local $oWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") If @error Then Return SetError(@error, 0, "") Local $oItems = $oWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%(COM%)'", "WQL", 48) $CommPort = "" For $oItem In $oItems $TestDevice = StringInStr($oItem.DeviceID, "FTDIBUS\VID_0403+PID_6001") If $TestDevice = 0 Then ContinueLoop EndIf $Leftprens = StringInStr($oItem.Name, "(") $Rightprens = StringInStr($oItem.Name, ")") $CommPort = StringMid($oItem.Name, $Leftprens + 1, $Rightprens - $Leftprens - 1) $NumericPort = Int(StringRight($CommPort, StringLen($CommPort) - 3)) If ($NumericPort > 9) Then $CommPort = "\\.\" & $CommPort EndIf Next Return $CommPort EndFunc