COMAte to get network card info
Posted: Wed Dec 15, 2021 10:44 pm
Got this so far, it will return the description and the MAC, but not the IP Address, any thoughts or suggestions? Pretty sure it's due to the IP's being in an array so it might have to be a variant type instead of string, but not sure how to query like that. The included COMAte demo_GetIPAddresses doesn't work either get a polink error....

Code: Select all
XIncludeFile "Includes\COMatePLus.pbi"
#COMATE_NOINCLUDEATL = 1
#COMATE_NOERRORREPORTING = 1
Procedure.s GetNetworkInfo()
;wmic nicconfig where ipenabled=true get description,ipaddress,macaddress
strComputer.s = ".";local computer
Define.COMateObject objWMIService, objItem
colNICinfo.COMateEnumObject
objWMIService = COMate_GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2")
If objWMIService
colNICinfo = objWMIService\CreateEnumeration("ExecQuery('Select * from Win32_NetworkAdapterConfiguration where IPEnabled=True')")
If colNICinfo
objItem = colNICinfo\GetNextObject()
While objItem
mynicdescription.s=objItem\GetStringProperty("Description")
myipaddress.s=objItem\GetStringProperty("IPAddress")
mymacaddress.s=objItem\GetStringProperty("MACAddress")
objItem = colNICinfo\GetNextObject()
nicinfo.s+mynicdescription+#CRLF$+"IP: "+myipaddress+#CRLF$+"MAC: "+mymacaddress+#CRLF$
Wend
colNICinfo\Release()
EndIf
objWMIService\Release()
Else
MessageRequester("Error", "Error retrieving network information."+#CRLF$+"Make sure you are running as an Administrator.",#MB_ICONERROR)
EndIf
ProcedureReturn nicinfo
EndProcedure
Debug GetNetworkInfo()