Jump to content

Ubound function not able to return number of objects in collection?


Go to solution Solved by argumentum,

Recommended Posts

Posted

Hello.  Consider the following code:

Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
Local $sQueryNetAdapter = 'select * from Win32_NetworkAdapter'
Local $colNetAdapter = $objWMIService.ExecQuery($sQueryNetAdapter, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$num = Ubound ( $colNetAdapter )
; Below Msgbox displays 0.  Why?  
MsgBox ( 1, "", $num )
; what I am trying to do
Local $storearray[$num][2]
$ind = 0
For $netadapt in $colNetAdapter
    $storearray[$ind][0] = $netadapt.Manufacturer
    $storearray[$ind][1] = $netadapt.ProductName
    $ind = $ind + 1
Next
return $storearray

As you can see, I have an array of objects that I want to query the size of so that I can use that value to create an empty 2-dimensional array with the same number of rows.  However, Ubound does not appear to work when trying to query the size of an array containing objects.  why is this?  Is this by design?  Is there another way that I should obtain this information.  I know I could just loop through the array of objects and record its size in a stored variable, but that seems inefficient.  Wanted to get the communities input.  

  • Solution
Posted (edited)
Spoiler
#include <Array.au3>

Opt("MustDeclareVars",1)
Opt("TrayIconDebug",1)
Opt("TrayAutoPause",0)
Global $_nice_COMerrorArray, $_nice_COMerrorObj
_nice_COMerrorHandler(1) ; COM error handler.

ToolTip("mouse over the trayicon for debug info.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)

Local $a = _WMI_Win32_NetworkAdapter()
If @error Then
    Switch @error
        Case 1
            MsgBox(262144, "WMI ScriptOMatic error", "No WMI Objects Found for class: ""Win32_NetworkAdapter""" )
        Case 2
            MsgBox(262144, "WMI ScriptOMatic error", "ObjGet failed")
        Case 3
            MsgBox(262144, "WMI ScriptOMatic error", "ObjCreate failed")
        Case 4
            MsgBox(262144, "WMI ScriptOMatic error", "ConnectServer failed")
        Case Else
            MsgBox(262144, "WMI ScriptOMatic error", "unknown error")
    EndSwitch
Else
    Switch @extended
        Case 0
            ToolTip("Done.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Case 1
            ToolTip("Nothing, you've got nothing."&@CR&@CR&"Adjust the query", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",2,4)
        Case 2
            ToolTip("More than you can chew."&@CR&@CR&"Adjust the ""$iLimit"" or the query", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",2,4)
    EndSwitch
    If $_nice_COMerrorArray[0][0] Then _nice_COMerrorHandler(2)
    _ArrayDisplay( $a ,"ScriptOMatic - ""Win32_NetworkAdapter""")
EndIf


Func _WMI_Win32_NetworkAdapter( $iLimit = 1000 , $sComputer = "." , $sUser = "" , $sPassword = "" )

    ; Generated by AutoIt ScriptOMatic

    ; Description: The Win32_NetworkAdapter class represents a network adapter on a Win32 system.


    ; Class Methods:
    ;
    ; SetPowerState
    ; Reset
    ; Enable
    ; Disable


    Local $wbemFlagReturnImmediately = 0x10
    Local $wbemFlagForwardOnly = 0x20
    Local $colItems = ""
    Local $sReturn=""
    Local $iExt = 0
    If 1 > Int( $iLimit ) Then $iLimit = 1
    Local $aReturn[1000][ Int( $iLimit ) + 1]
    $aReturn[0][0] = 0
    $aReturn[0][1] = 0
    Local $aErr[1][2] = [[0, 0]]

    If $sComputer & $sUser & $sPassword = "." Then
        ToolTip("...ObjGet", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Local $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\CIMV2")
        If Not IsObj($oWMIService) Then Return SetError(2, 99, $aErr)
    Else
        ToolTip("...ObjCreate", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Local $wmiLocator = ObjCreate("WbemScripting.SWbemLocator")
        If Not IsObj($wmiLocator) Then Return SetError(3, 99, $aErr)
        ToolTip("...ConnectServer", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Local $oWMIService = $wmiLocator.ConnectServer($sComputer, "\root\CIMV2", $sUser, $sPassword)
        If Not IsObj($oWMIService) Then Return SetError(4, 99, $aErr)
    EndIf

    ToolTip("...ExecQuery", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
    Local $colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", _
                         "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    ToolTip("...ExecQuery executed."& @CR &"...waiting for data.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
    If IsObj($colItems) Then

        ; Class Properties: Names:
        ;

        $aReturn[  1 ][ 0 ] = "AdapterType"
        $aReturn[  2 ][ 0 ] = "AdapterTypeId"
        $aReturn[  3 ][ 0 ] = "AutoSense"
        $aReturn[  4 ][ 0 ] = "Availability"
        $aReturn[  5 ][ 0 ] = "Caption"
        $aReturn[  6 ][ 0 ] = "ConfigManagerErrorCode"
        $aReturn[  7 ][ 0 ] = "ConfigManagerUserConfig"
        $aReturn[  8 ][ 0 ] = "CreationClassName"
        $aReturn[  9 ][ 0 ] = "Description"
        $aReturn[ 10 ][ 0 ] = "DeviceID"
        $aReturn[ 11 ][ 0 ] = "ErrorCleared"
        $aReturn[ 12 ][ 0 ] = "ErrorDescription"
        $aReturn[ 13 ][ 0 ] = "GUID"
        $aReturn[ 14 ][ 0 ] = "Index"
        $aReturn[ 15 ][ 0 ] = "InstallDate"
        $aReturn[ 16 ][ 0 ] = "Installed"
        $aReturn[ 17 ][ 0 ] = "InterfaceIndex"
        $aReturn[ 18 ][ 0 ] = "LastErrorCode"
        $aReturn[ 19 ][ 0 ] = "MACAddress"
        $aReturn[ 20 ][ 0 ] = "Manufacturer"
        $aReturn[ 21 ][ 0 ] = "MaxNumberControlled"
        $aReturn[ 22 ][ 0 ] = "MaxSpeed"
        $aReturn[ 23 ][ 0 ] = "Name"
        $aReturn[ 24 ][ 0 ] = "NetConnectionID"
        $aReturn[ 25 ][ 0 ] = "NetConnectionStatus"
        $aReturn[ 26 ][ 0 ] = "NetEnabled"
        $aReturn[ 27 ][ 0 ] = "NetworkAddresses"
        $aReturn[ 28 ][ 0 ] = "PermanentAddress"
        $aReturn[ 29 ][ 0 ] = "PhysicalAdapter"
        $aReturn[ 30 ][ 0 ] = "PNPDeviceID"
        $aReturn[ 31 ][ 0 ] = "PowerManagementCapabilities"
        $aReturn[ 32 ][ 0 ] = "PowerManagementSupported"
        $aReturn[ 33 ][ 0 ] = "ProductName"
        $aReturn[ 34 ][ 0 ] = "ServiceName"
        $aReturn[ 35 ][ 0 ] = "Speed"
        $aReturn[ 36 ][ 0 ] = "Status"
        $aReturn[ 37 ][ 0 ] = "StatusInfo"
        $aReturn[ 38 ][ 0 ] = "SystemCreationClassName"
        $aReturn[ 39 ][ 0 ] = "SystemName"
        $aReturn[ 40 ][ 0 ] = "TimeOfLastReset"
        $aReturn[0][0] = 40
        For $objItem In $colItems
            $aReturn[0][1] = $aReturn[0][1] + 1
            If Not Mod( $aReturn[0][1] , 100 ) Then ToolTip("...adding "& $aReturn[0][1] &" of "&$iLimit &" ??", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
            If $aReturn[0][1] > $iLimit Then
                $iExt = 2
                ExitLoop
            EndIf

            ; Class Properties: Values:
            ;

            $aReturn[  1 ][ $aReturn[0][1] ] = $objItem.AdapterType
            $aReturn[  2 ][ $aReturn[0][1] ] = $objItem.AdapterTypeId
            $aReturn[  3 ][ $aReturn[0][1] ] = $objItem.AutoSense
            $aReturn[  4 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_Availability( $objItem.Availability )
            $aReturn[  5 ][ $aReturn[0][1] ] = $objItem.Caption
            $aReturn[  6 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_ConfigManagerErrorCode( $objItem.ConfigManagerErrorCode )
            $aReturn[  7 ][ $aReturn[0][1] ] = $objItem.ConfigManagerUserConfig
            $aReturn[  8 ][ $aReturn[0][1] ] = $objItem.CreationClassName
            $aReturn[  9 ][ $aReturn[0][1] ] = $objItem.Description
            $aReturn[ 10 ][ $aReturn[0][1] ] = $objItem.DeviceID
            $aReturn[ 11 ][ $aReturn[0][1] ] = $objItem.ErrorCleared
            $aReturn[ 12 ][ $aReturn[0][1] ] = $objItem.ErrorDescription
            $aReturn[ 13 ][ $aReturn[0][1] ] = $objItem.GUID
            $aReturn[ 14 ][ $aReturn[0][1] ] = $objItem.Index
            $aReturn[ 15 ][ $aReturn[0][1] ] = WMIDateStringToDate( $objItem.InstallDate )
            $aReturn[ 16 ][ $aReturn[0][1] ] = $objItem.Installed
            $aReturn[ 17 ][ $aReturn[0][1] ] = $objItem.InterfaceIndex
            $aReturn[ 18 ][ $aReturn[0][1] ] = $objItem.LastErrorCode
            $aReturn[ 19 ][ $aReturn[0][1] ] = $objItem.MACAddress
            $aReturn[ 20 ][ $aReturn[0][1] ] = $objItem.Manufacturer
            $aReturn[ 21 ][ $aReturn[0][1] ] = $objItem.MaxNumberControlled
            $aReturn[ 22 ][ $aReturn[0][1] ] = $objItem.MaxSpeed
            $aReturn[ 23 ][ $aReturn[0][1] ] = $objItem.Name
            $aReturn[ 24 ][ $aReturn[0][1] ] = $objItem.NetConnectionID
            $aReturn[ 25 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_NetConnectionStatus( $objItem.NetConnectionStatus )
            $aReturn[ 26 ][ $aReturn[0][1] ] = $objItem.NetEnabled
            $aReturn[ 27 ][ $aReturn[0][1] ] = Array_Join( $objItem.NetworkAddresses )
            $aReturn[ 28 ][ $aReturn[0][1] ] = $objItem.PermanentAddress
            $aReturn[ 29 ][ $aReturn[0][1] ] = $objItem.PhysicalAdapter
            $aReturn[ 30 ][ $aReturn[0][1] ] = $objItem.PNPDeviceID
            $aReturn[ 31 ][ $aReturn[0][1] ] = Array_Join( $objItem.PowerManagementCapabilities )
            $aReturn[ 32 ][ $aReturn[0][1] ] = $objItem.PowerManagementSupported
            $aReturn[ 33 ][ $aReturn[0][1] ] = $objItem.ProductName
            $aReturn[ 34 ][ $aReturn[0][1] ] = $objItem.ServiceName
            $aReturn[ 35 ][ $aReturn[0][1] ] = $objItem.Speed
            $aReturn[ 36 ][ $aReturn[0][1] ] = $objItem.Status
            $aReturn[ 37 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_StatusInfo( $objItem.StatusInfo )
            $aReturn[ 38 ][ $aReturn[0][1] ] = $objItem.SystemCreationClassName
            $aReturn[ 39 ][ $aReturn[0][1] ] = $objItem.SystemName
            $aReturn[ 40 ][ $aReturn[0][1] ] = WMIDateStringToDate( $objItem.TimeOfLastReset )
        Next
        If $aReturn[0][1] = 0  Then $iExt = 1
        ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1] + 1]
        Return SetError( 0 , $iExt , $aReturn )
    Else
        Return SetError(1 ,99 ,$aErr)
    EndIf
EndFunc

Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 5, 2) & "/" & _
        StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
        & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Func Array_Join($aArray, $sSeparator = " , ")
    Local $n, $sOut = ""
    If IsObj($aArray) Then
        For $value In $aArray
            $sOut &= $value & $sSeparator
        Next
        Return StringTrimRight($sOut, StringLen($sSeparator))
    Else
        For $n = 0 To UBound($aArray) - 1
            $sOut &= $aArray[$n] & $sSeparator
        Next
        Return StringTrimRight($sOut, StringLen($sSeparator))
    EndIf
EndFunc   ;==>Array_Join

#Region    # ValueToDescription Functions #


Func Win32_NetworkAdapter_PropertyValues_Availability( $value )
    Switch $value
        Case "1"
            Return "1 = Other"
        Case "2"
            Return "2 = Unknown"
        Case "3"
            Return "3 = Running/Full Power"
        Case "4"
            Return "4 = Warning"
        Case "5"
            Return "5 = In Test"
        Case "6"
            Return "6 = Not Applicable"
        Case "7"
            Return "7 = Power Off"
        Case "8"
            Return "8 = Off Line"
        Case "9"
            Return "9 = Off Duty"
        Case "10"
            Return "10 = Degraded"
        Case "11"
            Return "11 = Not Installed"
        Case "12"
            Return "12 = Install Error"
        Case "13"
            Return "13 = Power Save - Unknown"
        Case "14"
            Return "14 = Power Save - Low Power Mode"
        Case "15"
            Return "15 = Power Save - Standby"
        Case "16"
            Return "16 = Power Cycle"
        Case "17"
            Return "17 = Power Save - Warning"
        Case "18"
            Return "18 = Paused"
        Case "19"
            Return "19 = Not Ready"
        Case "20"
            Return "20 = Not Configured"
        Case "21"
            Return "21 = Quiesced"
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc

Func Win32_NetworkAdapter_PropertyValues_ConfigManagerErrorCode( $value )
    Switch $value
        Case "0"
            Return "0 = This device is working properly."
        Case "1"
            Return "1 = This device is not configured correctly."
        Case "2"
            Return "2 = Windows cannot load the driver for this device."
        Case "3"
            Return "3 = The driver for this device might be corrupted, or your system may be running low on memory or other resources."
        Case "4"
            Return "4 = This device is not working properly. One of its drivers or your registry might be corrupted."
        Case "5"
            Return "5 = The driver for this device needs a resource that Windows cannot manage."
        Case "6"
            Return "6 = The boot configuration for this device conflicts with other devices."
        Case "7"
            Return "7 = Cannot filter."
        Case "8"
            Return "8 = The driver loader for the device is missing."
        Case "9"
            Return "9 = This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly."
        Case "10"
            Return "10 = This device cannot start."
        Case "11"
            Return "11 = This device failed."
        Case "12"
            Return "12 = This device cannot find enough free resources that it can use."
        Case "13"
            Return "13 = Windows cannot verify this device's resources."
        Case "14"
            Return "14 = This device cannot work properly until you restart your computer."
        Case "15"
            Return "15 = This device is not working properly because there is probably a re-enumeration problem."
        Case "16"
            Return "16 = Windows cannot identify all the resources this device uses."
        Case "17"
            Return "17 = This device is asking for an unknown resource type."
        Case "18"
            Return "18 = Reinstall the drivers for this device."
        Case "19"
            Return "19 = Failure using the VxD loader."
        Case "20"
            Return "20 = Your registry might be corrupted."
        Case "21"
            Return "21 = System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device."
        Case "22"
            Return "22 = This device is disabled."
        Case "23"
            Return "23 = System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation."
        Case "24"
            Return "24 = This device is not present, is not working properly, or does not have all its drivers installed."
        Case "25"
            Return "25 = Windows is still setting up this device."
        Case "26"
            Return "26 = Windows is still setting up this device."
        Case "27"
            Return "27 = This device does not have valid log configuration."
        Case "28"
            Return "28 = The drivers for this device are not installed."
        Case "29"
            Return "29 = This device is disabled because the firmware of the device did not give it the required resources."
        Case "30"
            Return "30 = This device is using an Interrupt Request (IRQ) resource that another device is using."
        Case "31"
            Return "31 = This device is not working properly because Windows cannot load the drivers required for this device."
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc

Func Win32_NetworkAdapter_PropertyValues_NetConnectionStatus( $value )
    Switch $value
        Case "0"
            Return "0 = Disconnected"
        Case "1"
            Return "1 = Connecting"
        Case "2"
            Return "2 = Connected"
        Case "3"
            Return "3 = Disconnecting"
        Case "4"
            Return "4 = Hardware Not Present"
        Case "5"
            Return "5 = Hardware Disabled"
        Case "6"
            Return "6 = Hardware Malfunction"
        Case "7"
            Return "7 = Media Disconnected"
        Case "8"
            Return "8 = Authenticating"
        Case "9"
            Return "9 = Authentication Succeeded"
        Case "10"
            Return "10 = Authentication Failed"
        Case "11"
            Return "11 = Invalid Address"
        Case "12"
            Return "12 = Credentials Required"
        Case ".."
            Return ".. = Other"
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc

Func Win32_NetworkAdapter_PropertyValues_StatusInfo( $value )
    Switch $value
        Case "1"
            Return "1 = Other"
        Case "2"
            Return "2 = Unknown"
        Case "3"
            Return "3 = Enabled"
        Case "4"
            Return "4 = Disabled"
        Case "5"
            Return "5 = Not Applicable"
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc


#EndRegion # ValueToDescription Functions #

Func _nice_COMerrorHandler($i = 0)
    If $i == 1 Then
        Dim $_nice_COMerrorArray[301][9]
        $_nice_COMerrorArray[0][0] = 0
        $_nice_COMerrorObj = ObjEvent("AutoIt.Error", "_nice_COMerrorHandler")
        Return
    EndIf
    If $i == 2 Then
        If Not @Compiled Then
            Local $n = 0, $c = 0, $s = FileRead(@ScriptFullPath)
            Local $a = StringSplit($s, @CRLF, 1)
            For $n = 1 To $_nice_COMerrorArray[0][0]
                If Int($_nice_COMerrorArray[$n][7]) > $a[0] Then ContinueLoop
                $_nice_COMerrorArray[$n][8] = StringStripWS($a[Int($_nice_COMerrorArray[$n][7])], 3)
            Next
            If StringInStr($s, "; only for the ANSI compiled version" & @CRLF) Then
                For $n = 1 To $a[0]
                    If StringInStr($a[$n], "; only for the ANSI compiled version") Then $c += 1
                    If $n > 50 Then ExitLoop
                Next
                For $n = 1 To $_nice_COMerrorArray[0][0]
                    $_nice_COMerrorArray[$n][7] = $_nice_COMerrorArray[$n][7] - $c
                Next
            EndIf
        EndIf
        $_nice_COMerrorArray[1][0] = ""
        ReDim $_nice_COMerrorArray[$_nice_COMerrorArray[0][0] + 1][9]
        _ArrayDisplay($_nice_COMerrorArray, "ScriptOMatic - COM Errors intercepted ( the script will continue after this screen )")
        Return
    EndIf
    If $_nice_COMerrorArray[0][0] = 300 Then
        $_nice_COMerrorArray[0][8] = "ScriptLine: only first 300 errors shown !!!"
        Return
    EndIf
    If StringInStr($_nice_COMerrorArray[1][0], "|" & $_nice_COMerrorObj.scriptline & "|") Then Return
    $i = $_nice_COMerrorArray[0][0] + 1
    $_nice_COMerrorArray[0][0] = $i
    $_nice_COMerrorArray[$i][1] = "0x" & Hex($_nice_COMerrorObj, 8)
    $_nice_COMerrorArray[$i][2] = $_nice_COMerrorObj.windescription
    $_nice_COMerrorArray[$i][3] = $_nice_COMerrorObj.source
    $_nice_COMerrorArray[$i][4] = $_nice_COMerrorObj.helpfile
    $_nice_COMerrorArray[$i][5] = $_nice_COMerrorObj.helpcontext
    $_nice_COMerrorArray[$i][6] = $_nice_COMerrorObj.lastdllerror
    $_nice_COMerrorArray[$i][7] = $_nice_COMerrorObj.scriptline
    $_nice_COMerrorArray[1][0] = $_nice_COMerrorArray[1][0] & "|" & $_nice_COMerrorObj.scriptline & "|"
    If $i == 1 Then
        $_nice_COMerrorArray[0][1] = "ErrorNumber:"
        $_nice_COMerrorArray[0][2] = "WinDescription:"
        $_nice_COMerrorArray[0][3] = "Source:"
        $_nice_COMerrorArray[0][4] = "HelpFile:"
        $_nice_COMerrorArray[0][5] = "HelpContext:"
        $_nice_COMerrorArray[0][6] = "LastDLLerror:"
        $_nice_COMerrorArray[0][7] = "ScriptLineNumber:"
        $_nice_COMerrorArray[0][8] = "ScriptLine:"
    EndIf
EndFunc   ;==>_nice_COMerrorHandler


#comments-start

List of all the Properties and Methods for \root\CIMV2:Win32_NetworkAdapter


Win32_NetworkAdapter Class Qualifiers
-------------------------------------

1. Description = The Win32_NetworkAdapter class represents a network adapter on a Win32 system.
2. dynamic = True
3. Locale = ms_409
4. provider = CIMWin32
5. UUID = {8502C4C0-5FBB-11D2-AAC1-006008C78BC7}


Win32_NetworkAdapter Class Properties and Property Qualifiers
-------------------------------------------------------------

1. AdapterType
1.1. CIMTYPE = string
1.2. Description = The AdapterType property reflects the network medium in use. This property may not be applicable to all types of network adapters listed within this class. Windows NT only.
1.3. MappingStrings = DeviceIoControl::OID_GEN_MEDIA_IN_USE
1.4. read = True
1.5. ValueMap = Ethernet 802.3,Token Ring 802.5,Fiber Distributed Data Interface (FDDI),Wide Area Network (WAN),LocalTalk,Ethernet using DIX header format,ARCNET,ARCNET (878.2),ATM,Wireless,Infrared Wireless,Bpc,CoWan,1394
1.6. Values = Ethernet 802.3,Token Ring 802.5,Fiber Distributed Data Interface (FDDI),Wide Area Network (WAN),LocalTalk,Ethernet using DIX header format,ARCNET,ARCNET (878.2),ATM,Wireless,Infrared Wireless,Bpc,CoWan,1394

2. AdapterTypeId
2.1. CIMTYPE = uint16
2.2. Description = The AdapterTypeId property reflects the network medium in use. This property gives the same information as the AdapterType property, except that the the information is returned in the form of an integer value that corresponds to the following: 
0 - Ethernet 802.3
1 - Token Ring 802.5
2 - Fiber Distributed Data Interface (FDDI)
3 - Wide Area Network (WAN)
4 - LocalTalk
5 - Ethernet using DIX header format
6 - ARCNET
7 - ARCNET (878.2)
8 - ATM
9 - Wireless
10 - Infrared Wireless
11 - Bpc
12 - CoWan
13 - 1394
This property may not be applicable to all types of network adapters listed within this class. Windows NT only.
2.3. MappingStrings = DeviceIoControl::OID_GEN_MEDIA_IN_USE
2.4. read = True
2.5. Values = Ethernet 802.3,Token Ring 802.5,Fiber Distributed Data Interface (FDDI),Wide Area Network (WAN),LocalTalk,Ethernet using DIX header format,ARCNET,ARCNET (878.2),ATM,Wireless,Infrared Wireless,Bpc,CoWan,1394

3. AutoSense
3.1. CIMTYPE = boolean
3.2. Description = A boolean indicating whether the NetworkAdapter is capable of automatically determining the speed or other communications characteristics of the attached network media.
3.3. read = True

4. Availability
4.1. CIMTYPE = uint16
4.2. Description = The availability and status of the device.  For example, the Availability property indicates that the device is running and has full power (value=3), or is in a warning (4), test (5), degraded (10) or power save state (values 13-15 and 17). Regarding the power saving states, these are defined as follows: Value 13 ("Power Save - Unknown") indicates that the device is known to be in a power save mode, but its exact status in this mode is unknown; 14 ("Power Save - Low Power Mode") indicates that the device is in a power save state but still functioning, and may exhibit degraded performance; 15 ("Power Save - Standby") describes that the device is not functioning but could be brought to full power 'quickly'; and value 17 ("Power Save - Warning") indicates that the device is in a warning state, though also in a power save mode.
4.3. MappingStrings = MIF.DMTF|Operational State|003.5,MIB.IETF|HOST-RESOURCES-MIB.hrDeviceStatus
4.4. read = True
4.5. ValueMap = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
4.6. Values = Other,Unknown,Running/Full Power,Warning,In Test,Not Applicable,Power Off,Off Line,Off Duty,Degraded,Not Installed,Install Error,Power Save - Unknown,Power Save - Low Power Mode,Power Save - Standby,Power Cycle,Power Save - Warning,Paused,Not Ready,Not Configured,Quiesced

5. Caption
5.1. CIMTYPE = string
5.2. Description = The Caption property is a short textual description (one-line string) of the object.
5.3. MaxLen = 64
5.4. read = True

6. ConfigManagerErrorCode
6.1. CIMTYPE = uint32
6.2. Description = Indicates the Win32 Configuration Manager error code.  The following values may be returned: 
0      This device is working properly. 
1      This device is not configured correctly. 
2      Windows cannot load the driver for this device. 
3      The driver for this device might be corrupted, or your system may be running low on memory or other resources. 
4      This device is not working properly. One of its drivers or your registry might be corrupted. 
5      The driver for this device needs a resource that Windows cannot manage. 
6      The boot configuration for this device conflicts with other devices. 
7      Cannot filter. 
8      The driver loader for the device is missing. 
9      This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. 
10     This device cannot start. 
11     This device failed. 
12     This device cannot find enough free resources that it can use. 
13     Windows cannot verify this device's resources. 
14     This device cannot work properly until you restart your computer. 
15     This device is not working properly because there is probably a re-enumeration problem. 
16     Windows cannot identify all the resources this device uses. 
17     This device is asking for an unknown resource type. 
18     Reinstall the drivers for this device. 
19     Your registry might be corrupted. 
20     Failure using the VxD loader. 
21     System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. 
22     This device is disabled. 
23     System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation. 
24     This device is not present, is not working properly, or does not have all its drivers installed. 
25     Windows is still setting up this device. 
26     Windows is still setting up this device. 
27     This device does not have valid log configuration. 
28     The drivers for this device are not installed. 
29     This device is disabled because the firmware of the device did not give it the required resources. 
30     This device is using an Interrupt Request (IRQ) resource that another device is using. 
31     This device is not working properly because Windows cannot load the drivers required for this device.
6.3. read = True
6.4. ValueMap = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
6.5. Values = This device is working properly.,This device is not configured correctly.,Windows cannot load the driver for this device.,The driver for this device might be corrupted, or your system may be running low on memory or other resources.,This device is not working properly. One of its drivers or your registry might be corrupted.,The driver for this device needs a resource that Windows cannot manage.,The boot configuration for this device conflicts with other devices.,Cannot filter.,The driver loader for the device is missing.,This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.,This device cannot start.,This device failed.,This device cannot find enough free resources that it can use.,Windows cannot verify this device's resources.,This device cannot work properly until you restart your computer.,This device is not working properly because there is probably a re-enumeration problem.,Windows cannot identify all the resources this device uses.,This device is asking for an unknown resource type.,Reinstall the drivers for this device.,Failure using the VxD loader.,Your registry might be corrupted.,System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.,This device is disabled.,System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation.,This device is not present, is not working properly, or does not have all its drivers installed.,Windows is still setting up this device.,Windows is still setting up this device.,This device does not have valid log configuration.,The drivers for this device are not installed.,This device is disabled because the firmware of the device did not give it the required resources.,This device is using an Interrupt Request (IRQ) resource that another device is using.,This device is not working properly because Windows cannot load the drivers required for this device.

7. ConfigManagerUserConfig
7.1. CIMTYPE = boolean
7.2. Description = Indicates whether the device is using a user-defined configuration.
7.3. read = True

8. CreationClassName
8.1. CIM_Key = True
8.2. CIMTYPE = string
8.3. Description = CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
8.4. read = True

9. Description
9.1. CIMTYPE = string
9.2. Description = The Description property provides a textual description of the object. 
9.3. read = True

10. DeviceID
10.1. CIM_Key = True
10.2. CIMTYPE = string
10.3. Description = The DeviceID property contains a string uniquely identifying the network adapter from other devices on the system.
10.4. key = True
10.5. MappingStrings = Win32Registry|System\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
10.6. Override = DeviceId
10.7. read = True

11. ErrorCleared
11.1. CIMTYPE = boolean
11.2. Description = ErrorCleared is a boolean property indicating that the error reported in LastErrorCode property is now cleared.
11.3. read = True

12. ErrorDescription
12.1. CIMTYPE = string
12.2. Description = ErrorDescription is a free-form string supplying more information about the error recorded in LastErrorCode property, and information on any corrective actions that may be taken.
12.3. read = True

13. GUID
13.1. CIMTYPE = string
13.2. Description = The GUID property specifies the Globally-unique identifier for the connection.
13.3. read = True

14. Index
14.1. CIMTYPE = uint32
14.2. Description = The Index property indicates the network adapter's  index number, which is stored in the system registry. 
Example: 0.
14.3. MappingStrings = Win32Registry|System\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
14.4. read = True

15. InstallDate
15.1. CIMTYPE = datetime
15.2. Description = The InstallDate property is datetime value indicating when the object was installed. A lack of a value does not indicate that the object is not installed.
15.3. MappingStrings = MIF.DMTF|ComponentID|001.5
15.4. read = True

16. Installed
16.1. CIMTYPE = boolean
16.2. DEPRECATED = True
16.3. Description = The Installed property determines whether the network adapter is installed in the system.
Values: TRUE or FALSE. A value of TRUE indicates the network adapter is installed.  
The Installed property has been deprecated.  There is no replacementvalue and this property is now considered obsolete.
16.4. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|DriverDate
16.5. read = True

17. InterfaceIndex
17.1. CIMTYPE = uint32
17.2. Description = The InterfaceIndex property contains the index value that uniquely identifies the local interface.
17.3. read = True

18. LastErrorCode
18.1. CIMTYPE = uint32
18.2. Description = LastErrorCode captures the last error code reported by the logical device.
18.3. read = True

19. MACAddress
19.1. CIMTYPE = string
19.2. Description = The MACAddress property indicates the media access control address for this network adapter. A MAC address is a unique 48-bit number assigned to the network adapter by the manufacturer. It uniquely identifies this network adapter and is used for mapping TCP/IP network communications.
19.3. MappingStrings = Win32API|Device Input and Output Functions|DeviceIoControl
19.4. read = True

20. Manufacturer
20.1. CIMTYPE = string
20.2. Description = The Manufacturer property indicates the name of the network adapter's manufacturer.
Example: 3COM.
20.3. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|Manufacturer
20.4. read = True

21. MaxNumberControlled
21.1. CIMTYPE = uint32
21.2. Description = The MaxNumberControlled property indicates the maximum number of directly addressable ports supported by this network adapter. A value of zero should be used if the number is unknown.
21.3. MappingStrings = MIF.DMTF|Bus Port|001.9|Maximum Number of Attachments
21.4. read = True

22. MaxSpeed
22.1. CIMTYPE = uint64
22.2. Description = The maximum speed, in bits per second, for the network adapter.
22.3. read = True
22.4. Units = bits per second

23. Name
23.1. CIMTYPE = string
23.2. Description = The Name property defines the label by which the object is known. When subclassed, the Name property can be overridden to be a Key property.
23.3. read = True

24. NetConnectionID
24.1. CIMTYPE = string
24.2. Description = The NetConnectionID property specifies the name of the network connection as it appears in the 'Network Connections' folder.
24.3. read = True
24.4. write = True

25. NetConnectionStatus
25.1. CIMTYPE = uint16
25.2. Description = NetConnectionStatus is a string indicating the state of the network adapter's connection to the network. The value of the property is to be interpreted as follows:
0 - Disconnected
1 - Connecting
2 - Connected
3 - Disconnecting
4 - Hardware not present
5 - Hardware disabled
6 - Hardware malfunction
7 - Media disconnected
8 - Authenticating
9 - Authentication succeeded
10 - Authentication failed
11 - Invalid Address
12 - Credentials Required
.. - Other - For integer values other than those listed above, refer to Win32 error code documentation.
25.3. read = True
25.4. ValueMap = 0,1,2,3,4,5,6,7,8,9,10,11,12,..
25.5. Values = Disconnected,Connecting,Connected,Disconnecting,Hardware Not Present,Hardware Disabled,Hardware Malfunction,Media Disconnected,Authenticating,Authentication Succeeded,Authentication Failed,Invalid Address,Credentials Required,Other

26. NetEnabled
26.1. CIMTYPE = boolean
26.2. Description = The NetEnabled property specifies whether the network connection is enabled or not.
26.3. read = True

27. NetworkAddresses
27.1. CIMTYPE = string
27.2. Description = An array of strings indicating the network addresses for an adapter.
27.3. MappingStrings = MIF.DMTF|Network Adapter 802 Port|001.3
27.4. MaxLen = 64
27.5. read = True

28. PermanentAddress
28.1. CIMTYPE = string
28.2. Description = PermanentAddress defines the network address hard coded into an adapter.  This 'hard coded' address may be changed via firmware upgrade or software configuration. If so, this field should be updated when the change is made.  PermanentAddress should be left blank if no 'hard coded' address exists for the network adapter.
28.3. MappingStrings = MIF.DMTF|Network Adapter 802 Port|001.2
28.4. MaxLen = 64
28.5. read = True

29. PhysicalAdapter
29.1. CIMTYPE = boolean
29.2. Description = The PhysicalAdapter property specifies whether the adapter is physical adapter or logical adapter.
29.3. read = True

30. PNPDeviceID
30.1. CIMTYPE = string
30.2. Description = Indicates the Win32 Plug and Play device ID of the logical device.  Example: *PNP030b
30.3. read = True

31. PowerManagementCapabilities
31.1. CIMTYPE = uint16
31.2. Description = Indicates the specific power-related capabilities of the logical device. The array values, 0="Unknown", 1="Not Supported" and 2="Disabled" are self-explanatory. The value, 3="Enabled" indicates that the power management features are currently enabled but the exact feature set is unknown or the information is unavailable. "Power Saving Modes Entered Automatically" (4) describes that a device can change its power state based on usage or other criteria. "Power State Settable" (5) indicates that the SetPowerState method is supported. "Power Cycling Supported" (6) indicates that the SetPowerState method can be invoked with the PowerState input variable set to 5 ("Power Cycle"). "Timed Power On Supported" (7) indicates that the SetPowerState method can be invoked with the PowerState input variable set to 5 ("Power Cycle") and the Time parameter set to a specific date and time, or interval, for power-on.
31.3. read = True
31.4. Values = Unknown,Not Supported,Disabled,Enabled,Power Saving Modes Entered Automatically,Power State Settable,Power Cycling Supported,Timed Power On Supported

32. PowerManagementSupported
32.1. CIMTYPE = boolean
32.2. Description = Boolean indicating that the Device can be power managed - ie, put into a power save state. This boolean does not indicate that power management features are currently enabled, or if enabled, what features are supported. Refer to the PowerManagementCapabilities array for this information. If this boolean is false, the integer value 1, for the string, "Not Supported", should be the only entry in the PowerManagementCapabilities array.
32.3. read = True

33. ProductName
33.1. CIMTYPE = string
33.2. Description = The ProductName property indicates the product name of the network adapter.
Example: Fast EtherLink XL
33.3. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|ServiceName
33.4. read = True

34. ServiceName
34.1. CIMTYPE = string
34.2. Description = The ServiceName property indicates the service name of the network adapter. This name is usually shorter that the full product name. 
Example: Elnkii.
34.3. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|ProductName
34.4. read = True

35. Speed
35.1. CIMTYPE = uint64
35.2. Description = An estimate of the current bandwidth in bits per second. For endpoints which vary in bandwidth or for those where no accurate estimation can be made, this property should contain the nominal bandwidth.
35.3. MappingStrings = MIB.IETF|RFC1213-MIB.ifSpeed,MIF.DMTF|Network Adapter 802 Port|001.5
35.4. read = True
35.5. Units = bits per second

36. Status
36.1. CIMTYPE = string
36.2. Description = The Status property is a string indicating the current status of the object. Various operational and non-operational statuses can be defined. Operational statuses are "OK", "Degraded" and "Pred Fail". "Pred Fail" indicates that an element may be functioning properly but predicting a failure in the near future. An example is a SMART-enabled hard drive. Non-operational statuses can also be specified. These are "Error", "Starting", "Stopping" and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is on-line, yet the managed element is neither "OK" nor in one of the other states.
36.3. MaxLen = 10
36.4. read = True
36.5. ValueMap = OK,Error,Degraded,Unknown,Pred Fail,Starting,Stopping,Service,Stressed,NonRecover,No Contact,Lost Comm
36.6. Values = OK,Error,Degraded,Unknown,Pred Fail,Starting,Stopping,Service,Stressed,NonRecover,No Contact,Lost Comm

37. StatusInfo
37.1. CIMTYPE = uint16
37.2. Description = StatusInfo is a string indicating whether the logical device is in an enabled (value = 3), disabled (value = 4) or some other (1) or unknown (2) state. If this property does not apply to the logical device, the value, 5 ("Not Applicable"), should be used.
37.3. MappingStrings = MIF.DMTF|Operational State|003.3
37.4. read = True
37.5. ValueMap = 1,2,3,4,5
37.6. Values = Other,Unknown,Enabled,Disabled,Not Applicable

38. SystemCreationClassName
38.1. CIM_Key = True
38.2. CIMTYPE = string
38.3. Description = The scoping System's CreationClassName.
38.4. Propagated = CIM_System.CreationClassName
38.5. read = True

39. SystemName
39.1. CIM_Key = True
39.2. CIMTYPE = string
39.3. Description = The scoping System's Name.
39.4. Propagated = CIM_System.Name
39.5. read = True

40. TimeOfLastReset
40.1. CIMTYPE = datetime
40.2. Description = The TimeOfLastReset property indicates when the network adapter was last reset.
40.3. MappingStrings = SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009|System Up Time
40.4. read = True


Win32_NetworkAdapter Class Methods and Method Qualifiers
--------------------------------------------------------

1. SetPowerState
1.1. Description = SetPowerState defines the desired power state for a logical device and when a device should be put into that state. The desired power state is specified by setting the PowerState parameter to one of the following integer values: 1="Full Power", 2="Power Save - Low Power Mode", 3="Power Save - Standby", 4="Power Save - Other", 5="Power Cycle" or 6="Power Off". The Time parameter (for all state changes, except 5, "Power Cycle") indicates when the power state should be set, either as a regular date-time value or as an interval value (where the interval begins when the method invocation is received). When the PowerState parameter is equal to 5, "Power Cycle", the Time parameter indicates when the device should power on again. Power off is immediate. SetPowerState should return 0 if successful, 1 if the specified PowerState and Time request is not supported, and some other value if any other error occurred. In a subclass, the set of possible return codes could be specified, using a ValueMap qualifier on the method. The strings to which the ValueMap contents are 'translated' may also be specified in the subclass as a Values array qualifier.

2. Reset
2.1. Description = Requests a reset of the logical device. The return value should be 0 if the request was successfully executed, 1 if the request is not supported and some other value if an error occurred.

3. Enable
3.1. Description = The Enable method enables the network adapter on the target computer. 
3.2. Implemented = True
3.3. MappingStrings = WMI

4. Disable
4.1. Description = The Disable method disables the network adapter on the target computer. 
4.2. Implemented = True
4.3. MappingStrings = WMI

#comments-end

..this is how I did it with script-o-matic.
Not your question but may solve your problem.

Edit: this looks nicer I think:

Spoiler
#include <Array.au3>

Opt("MustDeclareVars",1)
Opt("TrayIconDebug",1)
Opt("TrayAutoPause",0)
Global $_nice_COMerrorArray, $_nice_COMerrorObj
_nice_COMerrorHandler(1) ; COM error handler.

ToolTip("mouse over the trayicon for debug info.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)

Local $a = _WMI_Win32_NetworkAdapter()
If @error Then
    Switch @error
        Case 1
            MsgBox(262144, "WMI ScriptOMatic error", "No WMI Objects Found for class: ""Win32_NetworkAdapter""" )
        Case 2
            MsgBox(262144, "WMI ScriptOMatic error", "ObjGet failed")
        Case 3
            MsgBox(262144, "WMI ScriptOMatic error", "ObjCreate failed")
        Case 4
            MsgBox(262144, "WMI ScriptOMatic error", "ConnectServer failed")
        Case Else
            MsgBox(262144, "WMI ScriptOMatic error", "unknown error")
    EndSwitch
Else
    Switch @extended
        Case 0
            ToolTip("Done.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Case 1
            ToolTip("Nothing, you've got nothing."&@CR&@CR&"Adjust the query", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",2,4)
        Case 2
            ToolTip("More than you can chew."&@CR&@CR&"Adjust the ""$iLimit"" or the query", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",2,4)
    EndSwitch
    If $_nice_COMerrorArray[0][0] Then _nice_COMerrorHandler(2)
    _Array_Rotate2D( $a )
    _ArrayDisplay( $a ,"ScriptOMatic - ""Win32_NetworkAdapter""")
EndIf


Func _WMI_Win32_NetworkAdapter( $iLimit = 1000 , $sComputer = "." , $sUser = "" , $sPassword = "" )

    ; Generated by AutoIt ScriptOMatic

    ; Description: The Win32_NetworkAdapter class represents a network adapter on a Win32 system.


    ; Class Methods:
    ;
    ; SetPowerState
    ; Reset
    ; Enable
    ; Disable


    Local $wbemFlagReturnImmediately = 0x10
    Local $wbemFlagForwardOnly = 0x20
    Local $colItems = ""
    Local $sReturn=""
    Local $iExt = 0
    If 1 > Int( $iLimit ) Then $iLimit = 1
    Local $aReturn[1000][ Int( $iLimit ) + 1]
    $aReturn[0][0] = 0
    $aReturn[0][1] = 0
    Local $aErr[1][2] = [[0, 0]]

    If $sComputer & $sUser & $sPassword = "." Then
        ToolTip("...ObjGet", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Local $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\CIMV2")
        If Not IsObj($oWMIService) Then Return SetError(2, 99, $aErr)
    Else
        ToolTip("...ObjCreate", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Local $wmiLocator = ObjCreate("WbemScripting.SWbemLocator")
        If Not IsObj($wmiLocator) Then Return SetError(3, 99, $aErr)
        ToolTip("...ConnectServer", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
        Local $oWMIService = $wmiLocator.ConnectServer($sComputer, "\root\CIMV2", $sUser, $sPassword)
        If Not IsObj($oWMIService) Then Return SetError(4, 99, $aErr)
    EndIf

    ToolTip("...ExecQuery", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
    Local $colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", _
                         "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    ToolTip("...ExecQuery executed."& @CR &"...waiting for data.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
    If IsObj($colItems) Then

        ; Class Properties: Names:
        ;

        $aReturn[  1 ][ 0 ] = "AdapterType"
        $aReturn[  2 ][ 0 ] = "AdapterTypeId"
        $aReturn[  3 ][ 0 ] = "AutoSense"
        $aReturn[  4 ][ 0 ] = "Availability"
        $aReturn[  5 ][ 0 ] = "Caption"
        $aReturn[  6 ][ 0 ] = "ConfigManagerErrorCode"
        $aReturn[  7 ][ 0 ] = "ConfigManagerUserConfig"
        $aReturn[  8 ][ 0 ] = "CreationClassName"
        $aReturn[  9 ][ 0 ] = "Description"
        $aReturn[ 10 ][ 0 ] = "DeviceID"
        $aReturn[ 11 ][ 0 ] = "ErrorCleared"
        $aReturn[ 12 ][ 0 ] = "ErrorDescription"
        $aReturn[ 13 ][ 0 ] = "GUID"
        $aReturn[ 14 ][ 0 ] = "Index"
        $aReturn[ 15 ][ 0 ] = "InstallDate"
        $aReturn[ 16 ][ 0 ] = "Installed"
        $aReturn[ 17 ][ 0 ] = "InterfaceIndex"
        $aReturn[ 18 ][ 0 ] = "LastErrorCode"
        $aReturn[ 19 ][ 0 ] = "MACAddress"
        $aReturn[ 20 ][ 0 ] = "Manufacturer"
        $aReturn[ 21 ][ 0 ] = "MaxNumberControlled"
        $aReturn[ 22 ][ 0 ] = "MaxSpeed"
        $aReturn[ 23 ][ 0 ] = "Name"
        $aReturn[ 24 ][ 0 ] = "NetConnectionID"
        $aReturn[ 25 ][ 0 ] = "NetConnectionStatus"
        $aReturn[ 26 ][ 0 ] = "NetEnabled"
        $aReturn[ 27 ][ 0 ] = "NetworkAddresses"
        $aReturn[ 28 ][ 0 ] = "PermanentAddress"
        $aReturn[ 29 ][ 0 ] = "PhysicalAdapter"
        $aReturn[ 30 ][ 0 ] = "PNPDeviceID"
        $aReturn[ 31 ][ 0 ] = "PowerManagementCapabilities"
        $aReturn[ 32 ][ 0 ] = "PowerManagementSupported"
        $aReturn[ 33 ][ 0 ] = "ProductName"
        $aReturn[ 34 ][ 0 ] = "ServiceName"
        $aReturn[ 35 ][ 0 ] = "Speed"
        $aReturn[ 36 ][ 0 ] = "Status"
        $aReturn[ 37 ][ 0 ] = "StatusInfo"
        $aReturn[ 38 ][ 0 ] = "SystemCreationClassName"
        $aReturn[ 39 ][ 0 ] = "SystemName"
        $aReturn[ 40 ][ 0 ] = "TimeOfLastReset"
        $aReturn[0][0] = 40
        For $objItem In $colItems
            $aReturn[0][1] = $aReturn[0][1] + 1
            If Not Mod( $aReturn[0][1] , 100 ) Then ToolTip("...adding "& $aReturn[0][1] &" of "&$iLimit &" ??", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - Win32_NetworkAdapter",1,4)
            If $aReturn[0][1] > $iLimit Then
                $iExt = 2
                ExitLoop
            EndIf

            ; Class Properties: Values:
            ;

            $aReturn[  1 ][ $aReturn[0][1] ] = $objItem.AdapterType
            $aReturn[  2 ][ $aReturn[0][1] ] = $objItem.AdapterTypeId
            $aReturn[  3 ][ $aReturn[0][1] ] = $objItem.AutoSense
            $aReturn[  4 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_Availability( $objItem.Availability )
            $aReturn[  5 ][ $aReturn[0][1] ] = $objItem.Caption
            $aReturn[  6 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_ConfigManagerErrorCode( $objItem.ConfigManagerErrorCode )
            $aReturn[  7 ][ $aReturn[0][1] ] = $objItem.ConfigManagerUserConfig
            $aReturn[  8 ][ $aReturn[0][1] ] = $objItem.CreationClassName
            $aReturn[  9 ][ $aReturn[0][1] ] = $objItem.Description
            $aReturn[ 10 ][ $aReturn[0][1] ] = $objItem.DeviceID
            $aReturn[ 11 ][ $aReturn[0][1] ] = $objItem.ErrorCleared
            $aReturn[ 12 ][ $aReturn[0][1] ] = $objItem.ErrorDescription
            $aReturn[ 13 ][ $aReturn[0][1] ] = $objItem.GUID
            $aReturn[ 14 ][ $aReturn[0][1] ] = $objItem.Index
            $aReturn[ 15 ][ $aReturn[0][1] ] = WMIDateStringToDate( $objItem.InstallDate )
            $aReturn[ 16 ][ $aReturn[0][1] ] = $objItem.Installed
            $aReturn[ 17 ][ $aReturn[0][1] ] = $objItem.InterfaceIndex
            $aReturn[ 18 ][ $aReturn[0][1] ] = $objItem.LastErrorCode
            $aReturn[ 19 ][ $aReturn[0][1] ] = $objItem.MACAddress
            $aReturn[ 20 ][ $aReturn[0][1] ] = $objItem.Manufacturer
            $aReturn[ 21 ][ $aReturn[0][1] ] = $objItem.MaxNumberControlled
            $aReturn[ 22 ][ $aReturn[0][1] ] = $objItem.MaxSpeed
            $aReturn[ 23 ][ $aReturn[0][1] ] = $objItem.Name
            $aReturn[ 24 ][ $aReturn[0][1] ] = $objItem.NetConnectionID
            $aReturn[ 25 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_NetConnectionStatus( $objItem.NetConnectionStatus )
            $aReturn[ 26 ][ $aReturn[0][1] ] = $objItem.NetEnabled
            $aReturn[ 27 ][ $aReturn[0][1] ] = Array_Join( $objItem.NetworkAddresses )
            $aReturn[ 28 ][ $aReturn[0][1] ] = $objItem.PermanentAddress
            $aReturn[ 29 ][ $aReturn[0][1] ] = $objItem.PhysicalAdapter
            $aReturn[ 30 ][ $aReturn[0][1] ] = $objItem.PNPDeviceID
            $aReturn[ 31 ][ $aReturn[0][1] ] = Array_Join( $objItem.PowerManagementCapabilities )
            $aReturn[ 32 ][ $aReturn[0][1] ] = $objItem.PowerManagementSupported
            $aReturn[ 33 ][ $aReturn[0][1] ] = $objItem.ProductName
            $aReturn[ 34 ][ $aReturn[0][1] ] = $objItem.ServiceName
            $aReturn[ 35 ][ $aReturn[0][1] ] = $objItem.Speed
            $aReturn[ 36 ][ $aReturn[0][1] ] = $objItem.Status
            $aReturn[ 37 ][ $aReturn[0][1] ] = Win32_NetworkAdapter_PropertyValues_StatusInfo( $objItem.StatusInfo )
            $aReturn[ 38 ][ $aReturn[0][1] ] = $objItem.SystemCreationClassName
            $aReturn[ 39 ][ $aReturn[0][1] ] = $objItem.SystemName
            $aReturn[ 40 ][ $aReturn[0][1] ] = WMIDateStringToDate( $objItem.TimeOfLastReset )
        Next
        If $aReturn[0][1] = 0  Then $iExt = 1
        ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1] + 1]
        Return SetError( 0 , $iExt , $aReturn )
    Else
        Return SetError(1 ,99 ,$aErr)
    EndIf
EndFunc

Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 5, 2) & "/" & _
        StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
        & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Func _Array_Rotate2D(ByRef $a)
    Local $u1 = UBound($a, 1) - 1
    If @error Then Return SetError(1)
    Local $u2 = UBound($a, 2) - 1
    If @error Then
        Local $n, $m, $u2 = 1
        Local $b[$u2][$u1 + 1]
        For $n = 0 To $u1
            For $m = 0 To 0
                $b[$m][$n] = $a[$n]
            Next
        Next
    Else
        Local $n, $m
        Local $b[$u2 + 1][$u1 + 1]
        For $n = 0 To $u1
            For $m = 0 To $u2
                $b[$m][$n] = $a[$n][$m]
            Next
        Next
    EndIf
    $a = $b
EndFunc   ;==>_Array_Rotate2D

Func Array_Join($aArray, $sSeparator = " , ")
    Local $n, $sOut = ""
    If IsObj($aArray) Then
        For $value In $aArray
            $sOut &= $value & $sSeparator
        Next
        Return StringTrimRight($sOut, StringLen($sSeparator))
    Else
        For $n = 0 To UBound($aArray) - 1
            $sOut &= $aArray[$n] & $sSeparator
        Next
        Return StringTrimRight($sOut, StringLen($sSeparator))
    EndIf
EndFunc   ;==>Array_Join

#Region    # ValueToDescription Functions #


Func Win32_NetworkAdapter_PropertyValues_Availability( $value )
    Switch $value
        Case "1"
            Return "1 = Other"
        Case "2"
            Return "2 = Unknown"
        Case "3"
            Return "3 = Running/Full Power"
        Case "4"
            Return "4 = Warning"
        Case "5"
            Return "5 = In Test"
        Case "6"
            Return "6 = Not Applicable"
        Case "7"
            Return "7 = Power Off"
        Case "8"
            Return "8 = Off Line"
        Case "9"
            Return "9 = Off Duty"
        Case "10"
            Return "10 = Degraded"
        Case "11"
            Return "11 = Not Installed"
        Case "12"
            Return "12 = Install Error"
        Case "13"
            Return "13 = Power Save - Unknown"
        Case "14"
            Return "14 = Power Save - Low Power Mode"
        Case "15"
            Return "15 = Power Save - Standby"
        Case "16"
            Return "16 = Power Cycle"
        Case "17"
            Return "17 = Power Save - Warning"
        Case "18"
            Return "18 = Paused"
        Case "19"
            Return "19 = Not Ready"
        Case "20"
            Return "20 = Not Configured"
        Case "21"
            Return "21 = Quiesced"
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc

Func Win32_NetworkAdapter_PropertyValues_ConfigManagerErrorCode( $value )
    Switch $value
        Case "0"
            Return "0 = This device is working properly."
        Case "1"
            Return "1 = This device is not configured correctly."
        Case "2"
            Return "2 = Windows cannot load the driver for this device."
        Case "3"
            Return "3 = The driver for this device might be corrupted, or your system may be running low on memory or other resources."
        Case "4"
            Return "4 = This device is not working properly. One of its drivers or your registry might be corrupted."
        Case "5"
            Return "5 = The driver for this device needs a resource that Windows cannot manage."
        Case "6"
            Return "6 = The boot configuration for this device conflicts with other devices."
        Case "7"
            Return "7 = Cannot filter."
        Case "8"
            Return "8 = The driver loader for the device is missing."
        Case "9"
            Return "9 = This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly."
        Case "10"
            Return "10 = This device cannot start."
        Case "11"
            Return "11 = This device failed."
        Case "12"
            Return "12 = This device cannot find enough free resources that it can use."
        Case "13"
            Return "13 = Windows cannot verify this device's resources."
        Case "14"
            Return "14 = This device cannot work properly until you restart your computer."
        Case "15"
            Return "15 = This device is not working properly because there is probably a re-enumeration problem."
        Case "16"
            Return "16 = Windows cannot identify all the resources this device uses."
        Case "17"
            Return "17 = This device is asking for an unknown resource type."
        Case "18"
            Return "18 = Reinstall the drivers for this device."
        Case "19"
            Return "19 = Failure using the VxD loader."
        Case "20"
            Return "20 = Your registry might be corrupted."
        Case "21"
            Return "21 = System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device."
        Case "22"
            Return "22 = This device is disabled."
        Case "23"
            Return "23 = System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation."
        Case "24"
            Return "24 = This device is not present, is not working properly, or does not have all its drivers installed."
        Case "25"
            Return "25 = Windows is still setting up this device."
        Case "26"
            Return "26 = Windows is still setting up this device."
        Case "27"
            Return "27 = This device does not have valid log configuration."
        Case "28"
            Return "28 = The drivers for this device are not installed."
        Case "29"
            Return "29 = This device is disabled because the firmware of the device did not give it the required resources."
        Case "30"
            Return "30 = This device is using an Interrupt Request (IRQ) resource that another device is using."
        Case "31"
            Return "31 = This device is not working properly because Windows cannot load the drivers required for this device."
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc

Func Win32_NetworkAdapter_PropertyValues_NetConnectionStatus( $value )
    Switch $value
        Case "0"
            Return "0 = Disconnected"
        Case "1"
            Return "1 = Connecting"
        Case "2"
            Return "2 = Connected"
        Case "3"
            Return "3 = Disconnecting"
        Case "4"
            Return "4 = Hardware Not Present"
        Case "5"
            Return "5 = Hardware Disabled"
        Case "6"
            Return "6 = Hardware Malfunction"
        Case "7"
            Return "7 = Media Disconnected"
        Case "8"
            Return "8 = Authenticating"
        Case "9"
            Return "9 = Authentication Succeeded"
        Case "10"
            Return "10 = Authentication Failed"
        Case "11"
            Return "11 = Invalid Address"
        Case "12"
            Return "12 = Credentials Required"
        Case ".."
            Return ".. = Other"
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc

Func Win32_NetworkAdapter_PropertyValues_StatusInfo( $value )
    Switch $value
        Case "1"
            Return "1 = Other"
        Case "2"
            Return "2 = Unknown"
        Case "3"
            Return "3 = Enabled"
        Case "4"
            Return "4 = Disabled"
        Case "5"
            Return "5 = Not Applicable"
        Case Else
            Return $value&" = ???"
    EndSwitch
EndFunc


#EndRegion # ValueToDescription Functions #

Func _nice_COMerrorHandler($i = 0)
    If $i == 1 Then
        Dim $_nice_COMerrorArray[301][9]
        $_nice_COMerrorArray[0][0] = 0
        $_nice_COMerrorObj = ObjEvent("AutoIt.Error", "_nice_COMerrorHandler")
        Return
    EndIf
    If $i == 2 Then
        If Not @Compiled Then
            Local $n = 0, $c = 0, $s = FileRead(@ScriptFullPath)
            Local $a = StringSplit($s, @CRLF, 1)
            For $n = 1 To $_nice_COMerrorArray[0][0]
                If Int($_nice_COMerrorArray[$n][7]) > $a[0] Then ContinueLoop
                $_nice_COMerrorArray[$n][8] = StringStripWS($a[Int($_nice_COMerrorArray[$n][7])], 3)
            Next
            If StringInStr($s, "; only for the ANSI compiled version" & @CRLF) Then
                For $n = 1 To $a[0]
                    If StringInStr($a[$n], "; only for the ANSI compiled version") Then $c += 1
                    If $n > 50 Then ExitLoop
                Next
                For $n = 1 To $_nice_COMerrorArray[0][0]
                    $_nice_COMerrorArray[$n][7] = $_nice_COMerrorArray[$n][7] - $c
                Next
            EndIf
        EndIf
        $_nice_COMerrorArray[1][0] = ""
        ReDim $_nice_COMerrorArray[$_nice_COMerrorArray[0][0] + 1][9]
        _ArrayDisplay($_nice_COMerrorArray, "ScriptOMatic - COM Errors intercepted ( the script will continue after this screen )")
        Return
    EndIf
    If $_nice_COMerrorArray[0][0] = 300 Then
        $_nice_COMerrorArray[0][8] = "ScriptLine: only first 300 errors shown !!!"
        Return
    EndIf
    If StringInStr($_nice_COMerrorArray[1][0], "|" & $_nice_COMerrorObj.scriptline & "|") Then Return
    $i = $_nice_COMerrorArray[0][0] + 1
    $_nice_COMerrorArray[0][0] = $i
    $_nice_COMerrorArray[$i][1] = "0x" & Hex($_nice_COMerrorObj, 8)
    $_nice_COMerrorArray[$i][2] = $_nice_COMerrorObj.windescription
    $_nice_COMerrorArray[$i][3] = $_nice_COMerrorObj.source
    $_nice_COMerrorArray[$i][4] = $_nice_COMerrorObj.helpfile
    $_nice_COMerrorArray[$i][5] = $_nice_COMerrorObj.helpcontext
    $_nice_COMerrorArray[$i][6] = $_nice_COMerrorObj.lastdllerror
    $_nice_COMerrorArray[$i][7] = $_nice_COMerrorObj.scriptline
    $_nice_COMerrorArray[1][0] = $_nice_COMerrorArray[1][0] & "|" & $_nice_COMerrorObj.scriptline & "|"
    If $i == 1 Then
        $_nice_COMerrorArray[0][1] = "ErrorNumber:"
        $_nice_COMerrorArray[0][2] = "WinDescription:"
        $_nice_COMerrorArray[0][3] = "Source:"
        $_nice_COMerrorArray[0][4] = "HelpFile:"
        $_nice_COMerrorArray[0][5] = "HelpContext:"
        $_nice_COMerrorArray[0][6] = "LastDLLerror:"
        $_nice_COMerrorArray[0][7] = "ScriptLineNumber:"
        $_nice_COMerrorArray[0][8] = "ScriptLine:"
    EndIf
EndFunc   ;==>_nice_COMerrorHandler


#comments-start

List of all the Properties and Methods for \root\CIMV2:Win32_NetworkAdapter


Win32_NetworkAdapter Class Qualifiers
-------------------------------------

1. Description = The Win32_NetworkAdapter class represents a network adapter on a Win32 system.
2. dynamic = True
3. Locale = ms_409
4. provider = CIMWin32
5. UUID = {8502C4C0-5FBB-11D2-AAC1-006008C78BC7}


Win32_NetworkAdapter Class Properties and Property Qualifiers
-------------------------------------------------------------

1. AdapterType
1.1. CIMTYPE = string
1.2. Description = The AdapterType property reflects the network medium in use. This property may not be applicable to all types of network adapters listed within this class. Windows NT only.
1.3. MappingStrings = DeviceIoControl::OID_GEN_MEDIA_IN_USE
1.4. read = True
1.5. ValueMap = Ethernet 802.3,Token Ring 802.5,Fiber Distributed Data Interface (FDDI),Wide Area Network (WAN),LocalTalk,Ethernet using DIX header format,ARCNET,ARCNET (878.2),ATM,Wireless,Infrared Wireless,Bpc,CoWan,1394
1.6. Values = Ethernet 802.3,Token Ring 802.5,Fiber Distributed Data Interface (FDDI),Wide Area Network (WAN),LocalTalk,Ethernet using DIX header format,ARCNET,ARCNET (878.2),ATM,Wireless,Infrared Wireless,Bpc,CoWan,1394

2. AdapterTypeId
2.1. CIMTYPE = uint16
2.2. Description = The AdapterTypeId property reflects the network medium in use. This property gives the same information as the AdapterType property, except that the the information is returned in the form of an integer value that corresponds to the following: 
0 - Ethernet 802.3
1 - Token Ring 802.5
2 - Fiber Distributed Data Interface (FDDI)
3 - Wide Area Network (WAN)
4 - LocalTalk
5 - Ethernet using DIX header format
6 - ARCNET
7 - ARCNET (878.2)
8 - ATM
9 - Wireless
10 - Infrared Wireless
11 - Bpc
12 - CoWan
13 - 1394
This property may not be applicable to all types of network adapters listed within this class. Windows NT only.
2.3. MappingStrings = DeviceIoControl::OID_GEN_MEDIA_IN_USE
2.4. read = True
2.5. Values = Ethernet 802.3,Token Ring 802.5,Fiber Distributed Data Interface (FDDI),Wide Area Network (WAN),LocalTalk,Ethernet using DIX header format,ARCNET,ARCNET (878.2),ATM,Wireless,Infrared Wireless,Bpc,CoWan,1394

3. AutoSense
3.1. CIMTYPE = boolean
3.2. Description = A boolean indicating whether the NetworkAdapter is capable of automatically determining the speed or other communications characteristics of the attached network media.
3.3. read = True

4. Availability
4.1. CIMTYPE = uint16
4.2. Description = The availability and status of the device.  For example, the Availability property indicates that the device is running and has full power (value=3), or is in a warning (4), test (5), degraded (10) or power save state (values 13-15 and 17). Regarding the power saving states, these are defined as follows: Value 13 ("Power Save - Unknown") indicates that the device is known to be in a power save mode, but its exact status in this mode is unknown; 14 ("Power Save - Low Power Mode") indicates that the device is in a power save state but still functioning, and may exhibit degraded performance; 15 ("Power Save - Standby") describes that the device is not functioning but could be brought to full power 'quickly'; and value 17 ("Power Save - Warning") indicates that the device is in a warning state, though also in a power save mode.
4.3. MappingStrings = MIF.DMTF|Operational State|003.5,MIB.IETF|HOST-RESOURCES-MIB.hrDeviceStatus
4.4. read = True
4.5. ValueMap = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
4.6. Values = Other,Unknown,Running/Full Power,Warning,In Test,Not Applicable,Power Off,Off Line,Off Duty,Degraded,Not Installed,Install Error,Power Save - Unknown,Power Save - Low Power Mode,Power Save - Standby,Power Cycle,Power Save - Warning,Paused,Not Ready,Not Configured,Quiesced

5. Caption
5.1. CIMTYPE = string
5.2. Description = The Caption property is a short textual description (one-line string) of the object.
5.3. MaxLen = 64
5.4. read = True

6. ConfigManagerErrorCode
6.1. CIMTYPE = uint32
6.2. Description = Indicates the Win32 Configuration Manager error code.  The following values may be returned: 
0      This device is working properly. 
1      This device is not configured correctly. 
2      Windows cannot load the driver for this device. 
3      The driver for this device might be corrupted, or your system may be running low on memory or other resources. 
4      This device is not working properly. One of its drivers or your registry might be corrupted. 
5      The driver for this device needs a resource that Windows cannot manage. 
6      The boot configuration for this device conflicts with other devices. 
7      Cannot filter. 
8      The driver loader for the device is missing. 
9      This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. 
10     This device cannot start. 
11     This device failed. 
12     This device cannot find enough free resources that it can use. 
13     Windows cannot verify this device's resources. 
14     This device cannot work properly until you restart your computer. 
15     This device is not working properly because there is probably a re-enumeration problem. 
16     Windows cannot identify all the resources this device uses. 
17     This device is asking for an unknown resource type. 
18     Reinstall the drivers for this device. 
19     Your registry might be corrupted. 
20     Failure using the VxD loader. 
21     System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. 
22     This device is disabled. 
23     System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation. 
24     This device is not present, is not working properly, or does not have all its drivers installed. 
25     Windows is still setting up this device. 
26     Windows is still setting up this device. 
27     This device does not have valid log configuration. 
28     The drivers for this device are not installed. 
29     This device is disabled because the firmware of the device did not give it the required resources. 
30     This device is using an Interrupt Request (IRQ) resource that another device is using. 
31     This device is not working properly because Windows cannot load the drivers required for this device.
6.3. read = True
6.4. ValueMap = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
6.5. Values = This device is working properly.,This device is not configured correctly.,Windows cannot load the driver for this device.,The driver for this device might be corrupted, or your system may be running low on memory or other resources.,This device is not working properly. One of its drivers or your registry might be corrupted.,The driver for this device needs a resource that Windows cannot manage.,The boot configuration for this device conflicts with other devices.,Cannot filter.,The driver loader for the device is missing.,This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.,This device cannot start.,This device failed.,This device cannot find enough free resources that it can use.,Windows cannot verify this device's resources.,This device cannot work properly until you restart your computer.,This device is not working properly because there is probably a re-enumeration problem.,Windows cannot identify all the resources this device uses.,This device is asking for an unknown resource type.,Reinstall the drivers for this device.,Failure using the VxD loader.,Your registry might be corrupted.,System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.,This device is disabled.,System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation.,This device is not present, is not working properly, or does not have all its drivers installed.,Windows is still setting up this device.,Windows is still setting up this device.,This device does not have valid log configuration.,The drivers for this device are not installed.,This device is disabled because the firmware of the device did not give it the required resources.,This device is using an Interrupt Request (IRQ) resource that another device is using.,This device is not working properly because Windows cannot load the drivers required for this device.

7. ConfigManagerUserConfig
7.1. CIMTYPE = boolean
7.2. Description = Indicates whether the device is using a user-defined configuration.
7.3. read = True

8. CreationClassName
8.1. CIM_Key = True
8.2. CIMTYPE = string
8.3. Description = CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
8.4. read = True

9. Description
9.1. CIMTYPE = string
9.2. Description = The Description property provides a textual description of the object. 
9.3. read = True

10. DeviceID
10.1. CIM_Key = True
10.2. CIMTYPE = string
10.3. Description = The DeviceID property contains a string uniquely identifying the network adapter from other devices on the system.
10.4. key = True
10.5. MappingStrings = Win32Registry|System\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
10.6. Override = DeviceId
10.7. read = True

11. ErrorCleared
11.1. CIMTYPE = boolean
11.2. Description = ErrorCleared is a boolean property indicating that the error reported in LastErrorCode property is now cleared.
11.3. read = True

12. ErrorDescription
12.1. CIMTYPE = string
12.2. Description = ErrorDescription is a free-form string supplying more information about the error recorded in LastErrorCode property, and information on any corrective actions that may be taken.
12.3. read = True

13. GUID
13.1. CIMTYPE = string
13.2. Description = The GUID property specifies the Globally-unique identifier for the connection.
13.3. read = True

14. Index
14.1. CIMTYPE = uint32
14.2. Description = The Index property indicates the network adapter's  index number, which is stored in the system registry. 
Example: 0.
14.3. MappingStrings = Win32Registry|System\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
14.4. read = True

15. InstallDate
15.1. CIMTYPE = datetime
15.2. Description = The InstallDate property is datetime value indicating when the object was installed. A lack of a value does not indicate that the object is not installed.
15.3. MappingStrings = MIF.DMTF|ComponentID|001.5
15.4. read = True

16. Installed
16.1. CIMTYPE = boolean
16.2. DEPRECATED = True
16.3. Description = The Installed property determines whether the network adapter is installed in the system.
Values: TRUE or FALSE. A value of TRUE indicates the network adapter is installed.  
The Installed property has been deprecated.  There is no replacementvalue and this property is now considered obsolete.
16.4. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|DriverDate
16.5. read = True

17. InterfaceIndex
17.1. CIMTYPE = uint32
17.2. Description = The InterfaceIndex property contains the index value that uniquely identifies the local interface.
17.3. read = True

18. LastErrorCode
18.1. CIMTYPE = uint32
18.2. Description = LastErrorCode captures the last error code reported by the logical device.
18.3. read = True

19. MACAddress
19.1. CIMTYPE = string
19.2. Description = The MACAddress property indicates the media access control address for this network adapter. A MAC address is a unique 48-bit number assigned to the network adapter by the manufacturer. It uniquely identifies this network adapter and is used for mapping TCP/IP network communications.
19.3. MappingStrings = Win32API|Device Input and Output Functions|DeviceIoControl
19.4. read = True

20. Manufacturer
20.1. CIMTYPE = string
20.2. Description = The Manufacturer property indicates the name of the network adapter's manufacturer.
Example: 3COM.
20.3. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|Manufacturer
20.4. read = True

21. MaxNumberControlled
21.1. CIMTYPE = uint32
21.2. Description = The MaxNumberControlled property indicates the maximum number of directly addressable ports supported by this network adapter. A value of zero should be used if the number is unknown.
21.3. MappingStrings = MIF.DMTF|Bus Port|001.9|Maximum Number of Attachments
21.4. read = True

22. MaxSpeed
22.1. CIMTYPE = uint64
22.2. Description = The maximum speed, in bits per second, for the network adapter.
22.3. read = True
22.4. Units = bits per second

23. Name
23.1. CIMTYPE = string
23.2. Description = The Name property defines the label by which the object is known. When subclassed, the Name property can be overridden to be a Key property.
23.3. read = True

24. NetConnectionID
24.1. CIMTYPE = string
24.2. Description = The NetConnectionID property specifies the name of the network connection as it appears in the 'Network Connections' folder.
24.3. read = True
24.4. write = True

25. NetConnectionStatus
25.1. CIMTYPE = uint16
25.2. Description = NetConnectionStatus is a string indicating the state of the network adapter's connection to the network. The value of the property is to be interpreted as follows:
0 - Disconnected
1 - Connecting
2 - Connected
3 - Disconnecting
4 - Hardware not present
5 - Hardware disabled
6 - Hardware malfunction
7 - Media disconnected
8 - Authenticating
9 - Authentication succeeded
10 - Authentication failed
11 - Invalid Address
12 - Credentials Required
.. - Other - For integer values other than those listed above, refer to Win32 error code documentation.
25.3. read = True
25.4. ValueMap = 0,1,2,3,4,5,6,7,8,9,10,11,12,..
25.5. Values = Disconnected,Connecting,Connected,Disconnecting,Hardware Not Present,Hardware Disabled,Hardware Malfunction,Media Disconnected,Authenticating,Authentication Succeeded,Authentication Failed,Invalid Address,Credentials Required,Other

26. NetEnabled
26.1. CIMTYPE = boolean
26.2. Description = The NetEnabled property specifies whether the network connection is enabled or not.
26.3. read = True

27. NetworkAddresses
27.1. CIMTYPE = string
27.2. Description = An array of strings indicating the network addresses for an adapter.
27.3. MappingStrings = MIF.DMTF|Network Adapter 802 Port|001.3
27.4. MaxLen = 64
27.5. read = True

28. PermanentAddress
28.1. CIMTYPE = string
28.2. Description = PermanentAddress defines the network address hard coded into an adapter.  This 'hard coded' address may be changed via firmware upgrade or software configuration. If so, this field should be updated when the change is made.  PermanentAddress should be left blank if no 'hard coded' address exists for the network adapter.
28.3. MappingStrings = MIF.DMTF|Network Adapter 802 Port|001.2
28.4. MaxLen = 64
28.5. read = True

29. PhysicalAdapter
29.1. CIMTYPE = boolean
29.2. Description = The PhysicalAdapter property specifies whether the adapter is physical adapter or logical adapter.
29.3. read = True

30. PNPDeviceID
30.1. CIMTYPE = string
30.2. Description = Indicates the Win32 Plug and Play device ID of the logical device.  Example: *PNP030b
30.3. read = True

31. PowerManagementCapabilities
31.1. CIMTYPE = uint16
31.2. Description = Indicates the specific power-related capabilities of the logical device. The array values, 0="Unknown", 1="Not Supported" and 2="Disabled" are self-explanatory. The value, 3="Enabled" indicates that the power management features are currently enabled but the exact feature set is unknown or the information is unavailable. "Power Saving Modes Entered Automatically" (4) describes that a device can change its power state based on usage or other criteria. "Power State Settable" (5) indicates that the SetPowerState method is supported. "Power Cycling Supported" (6) indicates that the SetPowerState method can be invoked with the PowerState input variable set to 5 ("Power Cycle"). "Timed Power On Supported" (7) indicates that the SetPowerState method can be invoked with the PowerState input variable set to 5 ("Power Cycle") and the Time parameter set to a specific date and time, or interval, for power-on.
31.3. read = True
31.4. Values = Unknown,Not Supported,Disabled,Enabled,Power Saving Modes Entered Automatically,Power State Settable,Power Cycling Supported,Timed Power On Supported

32. PowerManagementSupported
32.1. CIMTYPE = boolean
32.2. Description = Boolean indicating that the Device can be power managed - ie, put into a power save state. This boolean does not indicate that power management features are currently enabled, or if enabled, what features are supported. Refer to the PowerManagementCapabilities array for this information. If this boolean is false, the integer value 1, for the string, "Not Supported", should be the only entry in the PowerManagementCapabilities array.
32.3. read = True

33. ProductName
33.1. CIMTYPE = string
33.2. Description = The ProductName property indicates the product name of the network adapter.
Example: Fast EtherLink XL
33.3. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|ServiceName
33.4. read = True

34. ServiceName
34.1. CIMTYPE = string
34.2. Description = The ServiceName property indicates the service name of the network adapter. This name is usually shorter that the full product name. 
Example: Elnkii.
34.3. MappingStrings = Win32Registry|Software\Microsoft\Windows NT\CurrentVersion\NetworkCards|ProductName
34.4. read = True

35. Speed
35.1. CIMTYPE = uint64
35.2. Description = An estimate of the current bandwidth in bits per second. For endpoints which vary in bandwidth or for those where no accurate estimation can be made, this property should contain the nominal bandwidth.
35.3. MappingStrings = MIB.IETF|RFC1213-MIB.ifSpeed,MIF.DMTF|Network Adapter 802 Port|001.5
35.4. read = True
35.5. Units = bits per second

36. Status
36.1. CIMTYPE = string
36.2. Description = The Status property is a string indicating the current status of the object. Various operational and non-operational statuses can be defined. Operational statuses are "OK", "Degraded" and "Pred Fail". "Pred Fail" indicates that an element may be functioning properly but predicting a failure in the near future. An example is a SMART-enabled hard drive. Non-operational statuses can also be specified. These are "Error", "Starting", "Stopping" and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is on-line, yet the managed element is neither "OK" nor in one of the other states.
36.3. MaxLen = 10
36.4. read = True
36.5. ValueMap = OK,Error,Degraded,Unknown,Pred Fail,Starting,Stopping,Service,Stressed,NonRecover,No Contact,Lost Comm
36.6. Values = OK,Error,Degraded,Unknown,Pred Fail,Starting,Stopping,Service,Stressed,NonRecover,No Contact,Lost Comm

37. StatusInfo
37.1. CIMTYPE = uint16
37.2. Description = StatusInfo is a string indicating whether the logical device is in an enabled (value = 3), disabled (value = 4) or some other (1) or unknown (2) state. If this property does not apply to the logical device, the value, 5 ("Not Applicable"), should be used.
37.3. MappingStrings = MIF.DMTF|Operational State|003.3
37.4. read = True
37.5. ValueMap = 1,2,3,4,5
37.6. Values = Other,Unknown,Enabled,Disabled,Not Applicable

38. SystemCreationClassName
38.1. CIM_Key = True
38.2. CIMTYPE = string
38.3. Description = The scoping System's CreationClassName.
38.4. Propagated = CIM_System.CreationClassName
38.5. read = True

39. SystemName
39.1. CIM_Key = True
39.2. CIMTYPE = string
39.3. Description = The scoping System's Name.
39.4. Propagated = CIM_System.Name
39.5. read = True

40. TimeOfLastReset
40.1. CIMTYPE = datetime
40.2. Description = The TimeOfLastReset property indicates when the network adapter was last reset.
40.3. MappingStrings = SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009|System Up Time
40.4. read = True


Win32_NetworkAdapter Class Methods and Method Qualifiers
--------------------------------------------------------

1. SetPowerState
1.1. Description = SetPowerState defines the desired power state for a logical device and when a device should be put into that state. The desired power state is specified by setting the PowerState parameter to one of the following integer values: 1="Full Power", 2="Power Save - Low Power Mode", 3="Power Save - Standby", 4="Power Save - Other", 5="Power Cycle" or 6="Power Off". The Time parameter (for all state changes, except 5, "Power Cycle") indicates when the power state should be set, either as a regular date-time value or as an interval value (where the interval begins when the method invocation is received). When the PowerState parameter is equal to 5, "Power Cycle", the Time parameter indicates when the device should power on again. Power off is immediate. SetPowerState should return 0 if successful, 1 if the specified PowerState and Time request is not supported, and some other value if any other error occurred. In a subclass, the set of possible return codes could be specified, using a ValueMap qualifier on the method. The strings to which the ValueMap contents are 'translated' may also be specified in the subclass as a Values array qualifier.

2. Reset
2.1. Description = Requests a reset of the logical device. The return value should be 0 if the request was successfully executed, 1 if the request is not supported and some other value if an error occurred.

3. Enable
3.1. Description = The Enable method enables the network adapter on the target computer. 
3.2. Implemented = True
3.3. MappingStrings = WMI

4. Disable
4.1. Description = The Disable method disables the network adapter on the target computer. 
4.2. Implemented = True
4.3. MappingStrings = WMI

#comments-end

 

 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

@argumentum Thank you for your response.  I will definitely look at the code you provided (that is a lot of code 😄), and use that to solve my coding needs.  However, as you kind of mentioned yourself, you helped me with one part of my question, but not the other.  I am not very knowledgeable when it comes to this aspect of autoit (working with objects), so my question is just as much to expand my understanding of autoit as it is to solve my coding problem. Specifically, why the Ubound function did not work in this case.  Is it because the variable that was passed to it is the result of an object method?  Are collections of objects that are returned by calling an object method not the same variable type as arrays as the ubound function understands it?  The for..in..next functionality seems to know that it is dealing with an array, so it just seems odd to me that ubound would fail.  

Edited by MattHiggs
Posted (edited)

.. it should be as simple as $oObj.Count but it isn't. 🤷‍♂️
So the script-o-matic code shows how it was done, using the For .. In looping. Wrote this a decade ago and, my memory sucks. But you can follow the code and pull what you need out of it.

Unless someone comes along with a better grasp on these things and answers your question :) 

PS: I've always being fond of you ( your nick ? ) and wanted to give you a possible solution. But you're after learning and I, personally have to learn everything all over again every time I jump into a project ( due to my memory problem ), hence my inability to give you an answer to something that I knew at the time.

Edited by argumentum
English

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

:unsure:

For $unused In $colNetAdapter
    $num += 1
Next


Edit:

#include <Array.au3>

$aResult = _zz()
_ArrayDisplay($aResult)

Func _zz()
    Local Const $wbemFlagReturnImmediately = 0x10
    Local Const $wbemFlagForwardOnly = 0x20
    Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
    Local $sQueryNetAdapter = 'select * from Win32_NetworkAdapter'
    Local $colNetAdapter = $objWMIService.ExecQuery($sQueryNetAdapter, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    Local $storearray[100][2]
    $ind = 0
    For $netadapt In $colNetAdapter
        $storearray[$ind][0] = $netadapt.Manufacturer
        $storearray[$ind][1] = $netadapt.ProductName
        $ind = $ind + 1
    Next
    ReDim $storearray[$ind][2]
    Return $storearray
EndFunc   ;==>_zz

 

Edited by ioa747

I know that I know nothing

Posted

If you dump the object you get, you can see it isn't an array:

Object
          Name:              SWbemObjectSet
          Description:       A collection of Classes or Instances
          Associated file:   C:\Windows\SysWOW64\wbem\wbemdisp.TLB
          Owner/marshaller:  C:\WINDOWS\system32\wbem\wbemdisp.dll
          CLSID:             {04B83D61-21AE-11D2-8B33-00600806D9B6}
          InterfaceID:       {76A6415F-CB41-11D1-8B02-00600806D9B6}

From AutoIt point of view, this is a flat variable, so UBound returns 0.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
8 hours ago, argumentum said:

.. it should be as simple as $oObj.Count but it isn't. 🤷‍♂️

I’ve identified the root cause of the issue with $colNetAdapter.Count failing when querying Win32_NetworkAdapter via WMI. The problem arises from using the wbemFlagForwardOnly flag (0x20) in the ExecQuery method. This flag creates a forward-only cursor for the SWbemObjectSet collection, which optimizes performance for large datasets by allowing only sequential, one-time access to objects. However, this cursor type does not support the .Count property, resulting in the error: "The requested action with this object has failed."To resolve this, you should use only the wbemFlagReturnImmediately flag (0x10) or no flags at all, as this ensures the resulting SWbemObjectSet collection supports .Count

 

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
If Not IsObj($objWMIService) Then
    MsgBox($MB_ICONERROR, "Error", "Unable to connect to WMI service. Check privileges or WMI service status.")
    Exit 1
EndIf


Local $sQueryNetAdapter = 'SELECT * FROM Win32_NetworkAdapter'
Local $colNetAdapter = $objWMIService.ExecQuery($sQueryNetAdapter, "WQL", 0x10) ; wbemFlagReturnImmediately
If Not IsObj($colNetAdapter) Then
    MsgBox($MB_ICONERROR, "Error", "WMI query failed. Check query syntax or access to Win32_NetworkAdapter class.")
    Exit 2
EndIf

; Get the number of items in the collection
Local $num = $colNetAdapter.Count
If @error Then
    MsgBox($MB_ICONERROR, "Error", "Unable to access .Count property. Error code: " & @error)
    Exit 3
EndIf
MsgBox($MB_OK, "Number of Adapters", "Number of network adapters: " & $num)

; Create an array to store the data
Local $storearray[$num][2]
Local $ind = 0
For $netadapt In $colNetAdapter
    If IsObj($netadapt) Then
        $storearray[$ind][0] = Not  $netadapt.Manufacturer ? "N/A" : $netadapt.Manufacturer
        $storearray[$ind][1] = Not  $netadapt.ProductName ? "N/A" : $netadapt.ProductName
        $ind += 1
    EndIf
Next

; Display the results (for verification)
For $i = 0 To $num - 1
    MsgBox($MB_OK, "Adapter " & $i, "Manufacturer: " & $storearray[$i][0] & @CRLF & "Product: " & $storearray[$i][1])
Next

 

Posted

You can simply do:

#include <MsgBoxConstants.au3>

; Connect to the WMI service
Local $wmiService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
If Not IsObj($wmiService) Then
    MsgBox($MB_ICONERROR, "Error", "Unable to connect to WMI service. Check privileges or service status.")
    Exit 1
EndIf

; Retrieve the collection of Win32_NetworkAdapter instances
Local $networkAdapterCol = $wmiService.InstancesOf('Win32_NetworkAdapter')
If Not IsObj($networkAdapterCol) Then
    MsgBox($MB_ICONERROR, "Error", "Failed to retrieve Win32_NetworkAdapter collection.")
    Exit 2
EndIf

; Get the number of items in the collection
Local $count = $networkAdapterCol.Count
MsgBox($MB_OK, "Number of Adapters", "Number of network adapters: " & $count)
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...