Jump to content

Appcrash using WMI - I'm stumped


Go to solution Solved by water,

Recommended Posts

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?

Link to comment
Share on other sites

  • Solution

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

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