Modify

Opened 11 years ago

Closed 11 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 Changed 11 years ago by anonymous

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 Changed 11 years ago by Jon

  • Resolution set to Works For Me
  • Status changed from new to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.