Sign in to follow this  
Followers 0
willichan

Appcrash using WMI - I'm stumped

5 posts in this topic

I am getting an appcrash when I call the following function from my script.

Func _NIClist()
    Local $NIC, $NIC2, $WMI_NA, $AType
    Local $ret = ""
    Local $WMIobj = ObjGet("winmgmts:\\localhost\")
    If Not IsObj($WMIobj) Then Return ""
    Local $WMI_NAC = $WMIobj.ExecQuery("SELECT DefaultIPGateway,Description,DHCPEnabled,DHCPServer,DNSDomain,Index,IPAddress,IPSubnet,MACAddress,SettingID FROM Win32_NetworkAdapterConfiguration WHERE MACAddress <> '' and MACAddress IS NOT NULL", "WQL", 0x30)
    If IsObj($WMI_NAC) Then
        For $NIC in $WMI_NAC
            If Not IsObj($NIC) Then ContinueLoop
            If $ret <> "" Then $ret &= "|-|"
            $ret &=       $NIC.DefaultIPGateway(0)
            $ret &= "|" & $NIC.Description
            $ret &= "|" & $NIC.DHCPEnabled
            $ret &= "|" & $NIC.DHCPServer
            $ret &= "|" & $NIC.DNSDomain
            $ret &= "|" & $NIC.IPAddress(0)
            $ret &= "|" & $NIC.IPSubnet(0)
            $ret &= "|" & $NIC.MACAddress
            $ret &= "|" & $NIC.SettingID
            $AType = ""
            $WMI_NA = $WMIobj.ExecQuery("SELECT AdapterType FROM Win32_NetworkAdapter WHERE Index = " & $NIC.Index, "WQL", 0x30)
            If IsObj($WMI_NA) Then
                For $NIC2 in $WMI_NA
                    $AType = $NIC2.AdapterType
                Next
            EndIf
            $ret &= "|" & $AType
        Next
    EndIf
    return $ret
EndFunc

The appcrash window contains the following

>>>> Window <<<<
Title:  AutoIt v3 Script
Class:  #32770
Position:   995, 12
Size:   507, 415
Style:  0x96CA0284
ExStyle:    0x00010109
Handle: 0x0000000000170DEA

>>>> Control <<<<
Class:  RichEdit20W
Instance:   1
ClassnameNN:    RichEdit20W1
Name:   
Advanced (Class):   [CLASS:RichEdit20W; INSTANCE:1]
ID: 
Text:   
Position:   10, 218
Size:   471, 150
ControlClick Coords:    344, 70
Style:  0x50B108C4
ExStyle:    0x00000000
Handle: 0x0000000000110D90

>>>> Mouse <<<<
Position:   1357, 330
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: autoit3.exe
  Application Version:  3.3.10.2
  Application Timestamp:    52c196bd
  Fault Module Name:    autoit3.exe
  Fault Module Version: 3.3.10.2
  Fault Module Timestamp:   52c196bd
  Exception Code:   c0000005
  Exception Offset: 0004b79d
  OS Version:   6.1.7601.2.1.0.256.27
  Locale ID:    1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt

Check online for a solution and close the program
Close the program


>>>> Hidden Text <<<<

I injected consolewrite statements between each line, to find where the problem was coming from, and it seems to happen on the last iteration, when I reference $NIC.DefaultIPGateway(0).  All of the iterations work perfectly except the last one, which caused AutoIt to crap out.

I am not sure what other error handling I could put in here to make it work.

Any thoughts?

Share this post


Link to post
Share on other sites



Could you test with the latest Beta Version of AutoIt too?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It has been fixed in the latest beta.  Here is the closed trac ticket. #2613

 

Adam

Share this post


Link to post
Share on other sites

Confirmed.  That was the problem.  It works perfectly with the latest beta.

Thanks.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0