Modify

Opened 12 years ago

Closed 12 years ago

#2454 closed Bug (Works For Me)

if WMI Obj need "Join",au3 crashed.

Reported by: thesnoW Owned by:
Milestone: Component: AutoIt
Version: 3.3.9.19 Severity: None
Keywords: Cc:

Description

the 2rd round work on old version
the 1rd round will crash with not object.

_NetworkAdapterInfo()		
Func _NetworkAdapterInfo()
	Local $colItems = ""
	Local $objWMIService
	Local $NetworkAdapterGateway = ""
	$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
	$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", 0x10 + 0x20)
	Local $colItem2 = $objWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus >0', "WQL", 0x10 + 0x20)
	If IsObj($colItems) Then
		For $objItem In $colItems
;1RD			
;~ 			If IsObj($objItem.DefaultIPGateway) Then
			FOR $Element IN $objItem.DefaultIPGateway
				$NetworkAdapterGateway= $Element
				MsgBox(32,"",$NetworkAdapterGateway)
			NEXT
;~ 			EndIf

;2RD
		MsgBox(32,"",$NetworkAdapterGateway(0))
		Next
	EndIf
EndFunc   ;==>_NetworkAdapterInfo

VBS version:
strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")

Attachments (0)

Change History (2)

comment:1 by anonymous, 12 years ago

This is not a bug. AutoIt has other methods. Here's an example:

; 2013-11-19_053721
Opt('MustDeclareVars', 1)

_NetworkAdapterInfo()

Func _NetworkAdapterInfo()
    Local $objWMIService = ObjGet('winmgmts:root\cimv2')
    Local $colItems = $objWMIService.InstancesOf('Win32_NetworkAdapterConfiguration WHERE IPEnabled = "True"')
    Local $count = $colItems.Count
    If Not $count Then Return
    MsgBox(0, 'Number of Items', $count)
    Local $Array, $strDefaultIPGateway = ''
    ;
    For $objItem In $colItems
        $Array = $objItem.DefaultIPGateway
        If IsArray($Array) Then
            For $Element In $Array
                $strDefaultIPGateway &= $Element & ','
            Next
        EndIf
    Next
    $strDefaultIPGateway = StringTrimRight($strDefaultIPGateway, 1)
    MsgBox(0, 'Gateway(s)', $strDefaultIPGateway)
EndFunc

comment:2 by Jon, 12 years ago

Resolution: Works For Me
Status: newclosed

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.