Try this
uses "WMI"
Uses "OS"
Uses "CONSOLE"
Dim vData() As String
Dim nItems As Long
Dim Counter As Long
Dim Position As Long
Dim ComputerName As String Value OS_GetComputerName
Dim sBuffer As String
Dim Ports() As String
sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_PnPEntity", "", "Name" )
'---Parse returned data into single lines
nItems = Parse( sBuffer, vData(), $CRLF)
'---Print lines
For Counter = 1 To nItems
Position = InStr(Ucase$(vData(Counter)),"(COM")
If Position Then
ReDim Preserve Ports(UBound(Ports)+1)
PortS(UBound(Ports)) = Extract$(Position+1,vData(Counter),")")
End If
Next
For Counter = LBound(Ports) To UBound(Ports)
Console_WriteLine Ports(Counter)
Next
2011-07-06 - Test02-01 : Update amended code to look for "(COM" instead of "COMM PORT" this is a better solution.
Bookmarks