Sign in to follow this  
Followers 0
katoNkatoNK

WMI Query specific objects

14 posts in this topic

#1 ·  Posted (edited)

Hi all

I'm having trouble getting a specific object from a WMI query from one function to the other, as far as i know it should be working :huh2:

The object return works for '_Get_aX_ID()' but not when trying to get it from '_Get_aX($aQuery)'

Take not of this, before testing..It applies to 'Get_aX_ID() and '$objValue'.

Windows XP with SP3 and later: This property returns a value of 2 for a client that is connected to an authenticated port.

Windows XP with SP2 and earlier: This property returns a value of 9 for a client that is connected to an authenticated port.

Windows 2000 and Windows NT 4.0: This property is not available.

I have also tried 'Description' instead of 'Name' in '_Get_aX_ID().

Global $xNIC[1][12]
Global $xNID[1][2]
Global $objHost = "localhost"
Global $objQuery = ''
Global $objValue = '2'

_Get_aX_ID()

For $i = 0 To UBound($xNID) - 1
    MsgBox(0, "Return", $xNID[$i][0])
Next

For $i = 0 To UBound($xNID) - 1
    MsgBox(0, "", _Get_aX($xNID[$i][0]))
Next

Func _Get_aX_ID()
    Local $found = False
    Local $nID = 0
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $objHost & "\root\cimv2")
    Local $oItems = $oWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus = ' & $objValue, "WQL", 0x30)
    If IsObj($oItems) Then
        For $objItem In $oItems
            ReDim $xNID[$nID + 1][2]
            $xNID[$nID][0] = _IsString($objItem.Name)
            $xNID[$nID][1] = _IsString($objItem.NetConnectionID)
            $nID += 1
            $found = True
        Next
    EndIf
    If Not $found Then Return "Win32_NetworkAdapter Class Failure"
EndFunc   ;==>_Get_aX_ID

Func _Get_aX($aQuery)
    Local $found = False
    Local $nIC = 0
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $objHost & "\root\CIMV2")
    Local $oItems = $oWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = " & $aQuery, "WQL", 0x30)
    If IsObj($oItems) Then
        For $objItem In $oItems
            ReDim $xNIC[$nIC + 1][12]
            $xNIC[$nIC][0] = _IsString($objItem.Description)
            $xNIC[$nIC][1] = _IsString($objItem.IPAddress(0))
            $xNIC[$nIC][2] = _IsString($objItem.IPSubNet)
            $xNIC[$nIC][3] = _IsString($objItem.DefaultIPGateway(0))
            $xNIC[$nIC][4] = _IsString($objItem.DNSServerSearchOrder(0))
            $xNIC[$nIC][5] = _IsString($objItem.DNSServerSearchOrder(1))
            $xNIC[$nIC][6] = _IsString($objItem.DHCPEnabled)
            $xNIC[$nIC][7] = _IsString($objItem.IPEnabled)
            $xNIC[$nIC][8] = _IsString($objItem.DHCPServer)
            $xNIC[$nIC][9] = _IsString($objItem.MACAddress)
            $xNIC[$nIC][10] = _IsString($objItem.Index)
            $xNIC[$nIC][11] = _IsString($objItem.SettingID)
            $nIC += 1
            $found = True
        Next
    EndIf
    If Not $found Then Return "Win32_NetworkAdapterConfiguration Class Failure"
EndFunc   ;==>_Get_aX

Func _IsString($sString)
    If IsString($sString) Then
        Return $sString
    EndIf
    Return "Not Available"
EndFunc   ;==>_IsString

Win32_NetworkAdapter

Win32_NetworkAdapterConfiguration

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this

$oWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = "' & $aQuery & '"'
& isn't _Get_aX() returning an Array if successful?

#include <Array.au3>

Global $xNIC[1][12]
Global $xNID[1][2]
Global $objHost = "localhost"
Global $objQuery = ''
Global $objValue = '2'

_Get_aX_ID()

For $i = 0 To UBound($xNID) - 1
    MsgBox(0, "Return", $xNID[$i][0])
Next

For $i = 0 To UBound($xNID, 2) - 1
    $aReturn = _Get_aX($xNID[$i][0])
    If @error Then
        MsgBox(0, "", $aReturn)
    Else
        _ArrayDisplay($xNIC) ; Testing Purposes!
    EndIf
Next

Func _Get_aX_ID()
    Local $found = False
    Local $nID = 0
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $objHost & "\root\cimv2")
    Local $oItems = $oWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus = ' & $objValue, "WQL", 0x30)
    If IsObj($oItems) Then
        For $objItem In $oItems
            ReDim $xNID[$nID + 1][2]
            $xNID[$nID][0] = _IsString($objItem.Name)
            $xNID[$nID][1] = _IsString($objItem.NetConnectionID)
            $nID += 1
            $found = True
        Next
    EndIf
    If Not $found Then Return "Win32_NetworkAdapter Class Failure"
EndFunc   ;==>_Get_aX_ID

Func _Get_aX($aQuery)
    Local $found = False
    Local $nIC = 0
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $objHost & "\root\CIMV2")
    Local $oItems = $oWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = "' & $aQuery & '"', "WQL", 0x30)
    If IsObj($oItems) Then
        For $objItem In $oItems
            ReDim $xNIC[$nIC + 1][12]
            $xNIC[$nIC][0] = _IsString($objItem.Description)
            $xNIC[$nIC][1] = _IsString($objItem.IPAddress(0))
            $xNIC[$nIC][2] = _IsString($objItem.IPSubNet)
            $xNIC[$nIC][3] = _IsString($objItem.DefaultIPGateway(0))
            $xNIC[$nIC][4] = _IsString($objItem.DNSServerSearchOrder(0))
            $xNIC[$nIC][5] = _IsString($objItem.DNSServerSearchOrder(1))
            $xNIC[$nIC][6] = _IsString($objItem.DHCPEnabled)
            $xNIC[$nIC][7] = _IsString($objItem.IPEnabled)
            $xNIC[$nIC][8] = _IsString($objItem.DHCPServer)
            $xNIC[$nIC][9] = _IsString($objItem.MACAddress)
            $xNIC[$nIC][10] = _IsString($objItem.Index)
            $xNIC[$nIC][11] = _IsString($objItem.SettingID)
            $nIC += 1
            $found = True
        Next
    EndIf
    If Not $found Then Return SetError(1, 0, "Win32_NetworkAdapterConfiguration Class Failure")
EndFunc   ;==>_Get_aX

Func _IsString($sString)
    If IsString($sString) Then
        Return $sString
    EndIf
    Return "Not Available"
EndFunc   ;==>_IsString

Edit: Plus I would do away with the Global variables as this can cause problems depending on how large your Script is. If you want I can show you how I would do it?

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

The quotes definately made a difference, the msgbox's are still only displaying "0", although the _ArrayDisplay works fine..

I'm having a look through your example now, and yes i'd like to know how to declare more 'efficiently'. :huh2:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here you are >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <Array.au3>

Global $aAdaper, $aID ; Required because these are not inside a Function.

$aID = _GetID()

For $A = 0 To UBound($aID, 1) - 1
    MsgBox(0, "Return From _GetID()", $aID[$A][0])
Next

For $A = 0 To UBound($aID, 1) - 1
    $aAdaper = _GetAdaperDetails($aID[$A][0])
    If @error Then
        MsgBox(0, "_GetAdaperDetails()", $aAdaper)
    Else
        _ArrayDisplay($aAdaper, "_GetAdaperDetails()") ; Testing Purposes!
    EndIf
Next

Func _GetID()
    Local $iConnection = 2, $sObjectHost = "localhost"
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $sObjectHost & "\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_NetworkAdapter Where NetConnectionStatus = ' & $iConnection, "WQL", 0x30)
    Local $aReturn[1][2], $iCount = 0, $iError = 1
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            ReDim $aReturn[$iCount + 1][2]
            $aReturn[$iCount][0] = _IsString($oObjectItem.Name)
            $aReturn[$iCount][1] = _IsString($oObjectItem.NetConnectionID)
            $iCount += 1
            $iError = 0
        Next
    EndIf
    If $iError Then
        $aReturn = "Win32_NetworkAdapter Class Failure"
    EndIf
    Return SetError($iError, 0, $aReturn)
EndFunc   ;==>_GetID

Func _GetAdaperDetails($sQuery)
    Local $sObjectHost = "localhost"
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $sObjectHost & "\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_NetworkAdapterConfiguration Where Description = "' & $sQuery & '"', "WQL", 0x30)
    Local $aReturn[1][12], $iCount = 0, $iError = 1
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            ReDim $aReturn[$iCount + 1][12]
            $aReturn[$iCount][0] = _IsString($oObjectItem.Description)
            $aReturn[$iCount][1] = _IsString($oObjectItem.IPAddress(0))
            $aReturn[$iCount][2] = _IsString($oObjectItem.IPSubNet)
            $aReturn[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0))
            $aReturn[$iCount][4] = _IsString($oObjectItem.DNSServerSearchOrder(0))
            $aReturn[$iCount][5] = _IsString($oObjectItem.DNSServerSearchOrder(1))
            $aReturn[$iCount][6] = _IsString($oObjectItem.DHCPEnabled)
            $aReturn[$iCount][7] = _IsString($oObjectItem.IPEnabled)
            $aReturn[$iCount][8] = _IsString($oObjectItem.DHCPServer)
            $aReturn[$iCount][9] = _IsString($oObjectItem.MACAddress)
            $aReturn[$iCount][10] = _IsString($oObjectItem.Index)
            $aReturn[$iCount][11] = _IsString($oObjectItem.SettingID)
            $iCount += 1
            $iError = 0
        Next
    EndIf
    If $iError Then
        $aReturn = "Win32_NetworkAdapterConfiguration Class Failure"
    EndIf
    Return SetError($iError, 0, $aReturn)
EndFunc   ;==>_GetAdaperDetails

Func _IsString($sString)
    If IsString($sString) Then
        Return $sString
    EndIf
    Return "Not Available"
EndFunc   ;==>_IsString

You would have noticed I use #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 in all of my Scripts to ensure variable declaration is correctly set & thus is less likely to cause problems. :huh2:

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ye i did notice, i did that, only after i had posted though, and do it every so often to my scripts ;)

Thanks for clean script!

My attempt at getting the 'Description' into a msgbox still isn't working for some reason.

I added this to below the two 'For..Next' loops: (As well as tried a few other variations)

For $A = 0 To UBound($aID) - 1
    $aAdaper = _GetAdapterDetails($aID[$A][0])
    MsgBox(0, "Return From _GetID()", $aAdaper)
Next

I'm trying to do it this way, so that maybe my understanding of 'Item referencing' & arrays might get better :huh2:

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

_GetAdapterDetails is Returning an Array if successful so if you want just the Description then point to Row 0 & Column 0 >>

For $A = 0 To UBound($aID) - 1
    $aAdaper = _GetAdapterDetails($aID[$A][0])
    MsgBox(0, "Return From _GetID()", $aAdaper[0][0])
Next

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

AH! I knew there was something fishy about the way i was doing it, just couldn't put two and two together.

Last question for today hopefully :huh2:

How would i get a only a single return from _GetAdapterDetails? ([0][0])

This is my attempt:

For $A = 0 To $aID[0][0]
    MsgBox(0, "Return From _GetID()", _GetAdapterDetails($aID[$A][0]))
Next
Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Without a huge edit like this >>

Func _GetAdaperDetails($sQuery)
    Local $sObjectHost = "localhost"
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $sObjectHost & "\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_NetworkAdapterConfiguration Where Description = "' & $sQuery & '"', "WQL", 0x30)
    Local $iCount = 0, $iError = 1, $sReturn
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            $sReturn = _IsString($oObjectItem.Description)
            $iError = 0
        Next
    EndIf
    If $iError Then
        $sReturn = "Win32_NetworkAdapterConfiguration Class Failure"
    EndIf
    Return SetError($iError, 0, $sReturn)
EndFunc   ;==>_GetAdaperDetails

But then it doesn't really require the Array unless its Global as in your first example i.e.

Global $aGlobalIPDetails[1][12]

Func _GetAdaperDetails($sQuery)
    Local $sObjectHost = "localhost"
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $sObjectHost & "\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_NetworkAdapterConfiguration Where Description = "' & $sQuery & '"', "WQL", 0x30)
    Local $iCount = 0, $iError = 1
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            ReDim $aGlobalIPDetails[$iCount + 1][12]
            $aGlobalIPDetails[$iCount][0] = _IsString($oObjectItem.Description)
            $aGlobalIPDetails[$iCount][1] = _IsString($oObjectItem.IPAddress(0))
            $aGlobalIPDetails[$iCount][2] = _IsString($oObjectItem.IPSubNet)
            $aGlobalIPDetails[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0))
            $aGlobalIPDetails[$iCount][4] = _IsString($oObjectItem.DNSServerSearchOrder(0))
            $aGlobalIPDetails[$iCount][5] = _IsString($oObjectItem.DNSServerSearchOrder(1))
            $aGlobalIPDetails[$iCount][6] = _IsString($oObjectItem.DHCPEnabled)
            $aGlobalIPDetails[$iCount][7] = _IsString($oObjectItem.IPEnabled)
            $aGlobalIPDetails[$iCount][8] = _IsString($oObjectItem.DHCPServer)
            $aGlobalIPDetails[$iCount][9] = _IsString($oObjectItem.MACAddress)
            $aGlobalIPDetails[$iCount][10] = _IsString($oObjectItem.Index)
            $aGlobalIPDetails[$iCount][11] = _IsString($oObjectItem.SettingID)
            $iCount += 1
            $iError = 0
        Next
    EndIf
    If $iError Then
        $aGlobalIPDetails[0][0] = "Win32_NetworkAdapterConfiguration Class Failure"     
    EndIf
    Return SetError($iError, 0, $aGlobalIPDetails[0][0])
EndFunc   ;==>_GetAdaperDetails
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Sori but I don't quite get it, or you understood me too literally :huh2:

Here's what i'm trying to do in the bigger picture.

I'm Creating menuitems's and combobox's data with the 'ConnectionID' (i've been able to this so far),

then a person clicks on one of them from the menu -> then using 'Name' from '_GetID()' it shows a msgbox/table

with all the info in it from _GetAdapterDetails (i guess when i'm able to do this, then i can use the same 'referencing' when the person chooses to write to an ini)

(I'll probably do away with the '.Description' and just use '.Name')

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

This Examples fails because $aID[0][0] doesn't contain the number of items, so best to use Ubound() (unless you change the Array structure to have $aArray[0][0] as the number of index's)

Also you asked "How would i get a only a single return from _GetAdapterDetails? ([0][0])" which is what I showed above in the first example. :huh2:

For $A = 0 To $aID[0][0] ; Use Ubound($aID, 1)
    MsgBox(0, "Return From _GetID()", _GetAdapterDetails($aID[$A][0])) ; This Returns an Array if successful.
Next

So why not do something like in my _IPDetails() Example with the MsgBox()?

Global $aArray = _GetAdapterDetails($aID[$A][0])
Global $sData = "Name: " & $aArray[0][1] & @LF & _
        "Example 2: " & $aArray[0][3] & @LF & _
        "Example 3: " & $aArray[0][4]
MsgBox(0, "_GetAdapterDetails()", $sData)

Let me know ;)

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I didn't mean it as far as only one object in the function :huh2: , I meant - How would I get a specific object when i need to? e.g. [0][0]

But anyway, your last post helped! I got it to work eventually - It took a while for me to get that '$aAdapter = _GetAdapterDetails($aID[$i][0])' was creating a whole new array on its own..

Global $aID = _GetID(), $sData, $aAdapter
Global $a = 0   ;e.g for $a = _GUICtrlCombo_GetCurSel($hWnd)
For $i = $a To $a
    $aAdapter = _GetAdapterDetails($aID[$i][0])
    $sData = "Description:" & $aID[$i][0] & @CRLF & _
             "IP Address:" & $aAdapter[0][0]
Next
MsgBox(0, "", $sData)

I can only really test it properly once i've figured out how get the handle array for the menu working, i've set the handle array without it giving any errors but it still wont respond - i've only managed to make the menu items from '_Get_aX_ID()' so far...

;..
Global $xNID[1][2]
Global $aX_View[2]  = [9999, 9999]
Func _Set_aX_ID()
    For $i = 0 To UBound($aX_View) - 1
        GUICtrlDelete($aX_View[$i])
    Next
    Global $aX_View[UBound($xNID) + 1]
    For $i = 0 To UBound($xNID) - 1
        $aX_View[$i] = GUICtrlCreateMenuItem($xNID[$i][0], $oView)
    Next
EndFunc

;..
$msg = GUIGetMsg()
$pReadx = GUICtrlRead($msg, 1)
;..
Case $aX_View[0] To $aX_View[UBound($aX_View) - 1]
    MsgBox(0, $pReadx, $pReadx)

Any help on this would be great!

Edit: I've looked through basically all of the examples i could find aswell as something else i got help on:

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Here's the working piece from my script.. it does what it should but only sets one adapter's menu item when there should be three, and the gui freezes up from the

'$aID = _Get_aX_ID()' in the loop but i don't know how else i could do it, i assume there is a better way to update the menu items?

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Misc.au3>
#include <Array.au3>
#Include <GuiMenu.au3>
#include <Constants.au3>
#include <SendMessage.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#Include <GuiComboBox.au3>

Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 3)
Opt('TrayAutoPause', 0)

Global $objHost = "localhost", $objValue = '2'
Global $sData, $aID, $aAdapter
Global $oView, $tOview, $Combo, $Av, $Ag
Global $aX_View[2]  = [9999, 9999]
Global $aX_tView[2] = [9999, 9999]
Global $aX_Combo[2] = [9999, 9999]
Global $aX_Adv[2] = [9999, 9999]
Global $aX_Current, $aX_New, $aX_Last
Global $gCMD = _WinAPI_RegisterWindowMessage("LazyIP"), $msg, $pReadx

;======================================================================================================================================================
If _Singleton("LazyIP", 1) = 0 Then
    MsgBox(0, "LazyIP", "An instance of LazyIP is already running!")
    Global $wH = WinGetHandle("LazyIP")
    If @error = 0 Then
        _SendMessage($wH, $gCMD, 1)
    Else
        MsgBox(0, "Error!", "Instance occurence error!")
    EndIf
    Exit
EndIf
;======================================================================================================================================================
_StartUp()
Func _StartUp()
    $aID = _Get_aX_ID()
    If IsArray($aID) Then MsgBox(0, "Array", "Array")
    For $i = 0 To $aID[UBound($aID) - 1][0] ;UBound($aID) - 1 ~ gives subscript error.
        $aAdapter = _Get_aX($aID[$i][1])
        $sData = "Description:" & $aAdapter[$i][0] & @CRLF & _
                "IP Address:" & $aAdapter[$i][1]
        MsgBox(0, "_StartUp()", $sData) ;should show 3 msgbox's, only shows 1.
    Next
    _CompatibilityCheck()
    If @Error Then
        Switch @Error
            Case 1
                If MsgBox(1, "OS Error!", "The WMI Class used in this config are not supported by Windows 2000." & @CRLF & "If you choose to continue the 'WMI Class' may not function properly!") = 1 Then
                    LazyIP()
                Else
                    Exit
                EndIf
            Case 2
                If MsgBox(0, "OS Error!", "Your Operating System could not be detected by LazyIP" & @CRLF & "If you choose to continue the 'WMI Class' may not function properly!") = 1 Then
                    LazyIP()
                Else
                    Exit
                EndIf
            Case 3
                If MsgBox(1, "OS Error!", "LazyIP was built for a Windows Operating System only." & @CRLF & "If you choose to continue the 'WMI Class' may not function properly!") = 1 Then
                    LazyIP()
                Else
                    Exit
                EndIf
        EndSwitch
    Else
        LazyIP()
    EndIf
EndFunc   ;==>FileCheck
;======================================================================================================================================================
Func LazyIP()
    Local $gui, $oMenu, $tOptions, $tExit, $read, $check, $gui2
;------------------------------------------------------------------------------------------------------------------------------------------------------
    $gui = GUICreate("LazyIP", 325, 395, -1, -1)
;------------------------------------------------------------------------------------------------------------------------------------------------------
    $oMenu      = GUICtrlCreateMenu("Options")
    $oView      = GUICtrlCreateMenu("View", $oMenu)
    GUICtrlCreateMenuItem("Adapter Info", $oView)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateMenuItem("", $oView)
    $combo = GUICtrlCreateCombo("", 50, 50, 200, 20)
    $read = GUICtrlCreateButton("Read Combo", 50, 80, 100, 20)
    $check = GUICtrlCreateButton("Exists?", 50, 110, 100, 20)
    $gui2 = GUICtrlCreateButton("gui2", 50, 170, 100, 20)
    
    $tOptions   = TrayCreateMenu("Options")
    $tOview     = TrayCreateMenu("View", $tOptions)
    $tExit = TrayCreateItem("Exit")
    TrayCreateItem("Current", $tOview)
    TrayItemSetState(-1, $TRAY_DISABLE)
    TrayCreateItem("", $tOview)

        If IsArray($aID) Then
            _Set_aX_ID()
        Else
            MsgBox(0, "Get ID Error!", "No array.")
        EndIf
        
    GUISetState()
    TraySetClick(24)
    TraySetState(2)

    GUIRegisterMsg($gCMD, "WM_COMMAND")
;----------
    While 1
        $msg = GUIGetMsg(1)
        $pReadx = GUICtrlRead($msg, 1)

        $aID = _Get_aX_ID()

            If IsArray($aID) Then   ;Update flag for menu items
                $aX_Current = $aID
                $aX_New = ""
                For $i = 0 To $aX_Current[0][0]
                    $aX_New = $aX_New & $aX_Current[$i][$i]
                Next
                If $aX_New <> $aX_Last Then
                    _Set_aX_ID()
                EndIf
            EndIf

        Switch $msg[1]
            Case $gui
                Switch $msg[0]
                    Case $gui2
                        _AdvancedGUI()
                    Case $aX_View[0] To $aX_View[UBound($aX_View) - 1]  ;handle
                        MsgBox(0, "gui1", $pReadx)
                    Case $Read
                        If IsArray($aID) Then MsgBox(0, "Array", "Array")
                        Local $iCombo = _GUICtrlComboBox_GetCurSel($Combo)
                        For $i = $iCombo To $iCombo
                            $aAdapter = _Get_aX($aID[$i][1])
                            MsgBox(0, $aID[$i][0], $aAdapter[$i][0] & @CRLF & $aAdapter[$i][1] & @CRLF & $aAdapter[$i][2] & @CRLF & $aAdapter[$i][3] & @CRLF & $aAdapter[$i][4])
                        Next
                        ;If IsArray($aID) Then MsgBox(0, "Array", "Array")
                        ;For $i = 0 To $aID[UBound($aID) - 1][0]    ;UBound($aID) - 1 ~ gives subscript error.
                        ;   $aAdapter = _Get_aX($aID[$i][1])
                        ;   $sData = "Description:" & $aAdapter[$i][0] & @CRLF & _
                        ;           "IP Address:" & $aAdapter[$i][1]
                        ;   MsgBox(0, "", $sData)   ;should show 3 msgbox's, only shows 1.
                        ;Next
                        Case $check
                            Local $aCheck = GUICtrlRead($Combo)
                            If $aCheck <> "" Then
                                For $i = 0 To UBound($aID) - 1
                                    If $aCheck <> $aID[$i][0] Then MsgBox(0, "", "Adapter not found.")
                                Next
                            Else
                                MsgBox(0, "", "Select Adapter.")
                            EndIf
                    Case $GUI_EVENT_MINIMIZE
                        GUISetState(@SW_HIDE)
                        TraySetState()
                    Case $GUI_EVENT_CLOSE
                        Exit
                EndSwitch
            ;Case $Ag
            ;   Switch $msg[0]
            ;       Case $aX_Adv[0] To $aX_Adv[UBound($aX_Adv) - 1]
            ;           MsgBox(0, "gui2", $pReadx)
            ;       Case $GUI_EVENT_CLOSE
            ;           GUIDelete()
            ;   EndSwitch
        EndSwitch       
    
        Local $tMsg = TrayGetMsg()
        Local $pReadt = TrayItemGetText($tMsg)
        Switch $tMsg
            Case $aX_tView[0] To $aX_tView[UBound($aX_tView) - 1]   ;handle
                MsgBox(0, "tray", $pReadt)
            Case $TRAY_EVENT_PRIMARYUP
                GUISetState()
                WinActivate($gui)
                TraySetState(2)
            Case $tExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>LazyIP

Func _AdvancedGUI()
    
    $Ag = GUICreate("Advanced..", 300, 350, -1, -1)
    $Av = GUICtrlCreateMenu("View")
    
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $aX_Adv[0] To $aX_Adv[UBound($aX_Adv) - 1]
                    MsgBox(0, "gui2", $pReadx)
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc
;======================================================================================================================================================
Func _Set_aX_ID()   ;refresh menu items
        If IsArray($aID) Then
            For $i = 0 To UBound($aX_View) - 1
                GUICtrlDelete($aX_View[$i])
            Next
            Global $aX_tView[UBound($aID)]

            For $i = 0 To UBound($aX_tView) - 1
                GUICtrlDelete($aX_tView[$i])
            Next
            Global $aX_tView[UBound($aID)]

            For $i = 0 To UBound($aX_Combo) - 1
                GUICtrlDelete($aX_Combo[$i])
            Next
            Global $aX_combo[UBound($aID)]
            
            For $i = 0 To UBound($aX_Adv) - 1
                GUICtrlDelete($aX_Adv[$i])
            Next
            Global $aX_Adv[UBound($aID)]
            
            $aID = _Get_aX_ID()

            For $i = 0 To $aID[0][0]
                $aX_View[$i] = GUICtrlCreateMenuItem($aID[$i][0], $oView)
            Next
            For $i = 0 To $aID[0][0]
                $aX_tView[$i] = TrayCreateItem($aID[$i][0], $tOview)
            Next
            For $i = 0 To $aID[0][0]
                $aX_Combo[$i] = GUICtrlSetData($Combo, $aID[$i][0])
            Next
            For $i = 0 To $aID[0][0]
                $aX_Adv[$i] = GUICtrlCreateMenuItem($aID[$i][0], $Av)
            Next
            
            $aX_Last = ""
            For $i = 0 To $aID[0][0]
                $aX_Last = $aX_Last & $aID[$i][$i]
            Next
        EndIf
EndFunc

Func _Get_aX_ID()
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $objHost & "\root\cimv2")
    Local $oItems = $oWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus = ' & $objValue, "WQL", 0x30)
    Global $xNID[1][2], $nID = 0, $iError = 1
    If IsObj($oItems) Then
        For $objItem In $oItems
            ReDim $xNID [$nID + 1] [2]
            $xNID [$nID] [0] = _IsString($objItem.NetConnectionID)
            $xNID [$nID] [1] = _IsString($objItem.Name)
            $nID += 1
            $iError = 0
        Next
    Else
        MsgBox(0, "WMI Class Failure!", "WMI Class - 'Win32_NetworkAdapter' has encountered an error!")
    EndIf
    If $iError Then
        $xNID = "Win32_NetworkAdapter Class Failure"
    EndIf
    Return SetError($iError, 0, $xNID)
EndFunc   ;==>_Get_aX_ID

Func _Get_aX($objQuery)
    Local $oWMIservice = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $objHost & "\root\CIMV2")
    Local $oItems = $oWMIservice.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = "' & $objQuery & '"', "WQL", 0x30)
    Global $xNIC[1][14], $nIC = 0, $iError = 1
    If IsObj($oItems) Then
        For $objItem In $oItems
            ReDim $xNIC [$nIC + 1] [14]
            $xNIC [$nIC] [0] = _IsString($objItem.Description)
            $xNIC [$nIC] [1] = _IsString($objItem.IPAddress(0))
            $xNIC [$nIC] [2] = _IsString($objItem.IPSubNet)
            $xNIC [$nIC] [3] = _IsString($objItem.DefaultIPGateway(0))
            $xNIC [$nIC] [4] = _IsString($objItem.DNSServerSearchOrder(0))
            $xNIC [$nIC] [5] = _IsString($objItem.DNSServerSearchOrder(1))
            $xNIC [$nIC] [6] = $objItem.DHCPEnabled ;boolean
            $xNIC [$nIC] [7] = $objItem.IPEnabled   ;boolean
            $xNIC [$nIC] [8] = _IsString($objItem.DHCPServer)
            $xNIC [$nIC] [9] = _IsString($objItem.MACAddress)
            $xNIC [$nIC] [10] = $objItem.Index      ;uint32
            $xNIC [$nIC] [11] = _IsString($objItem.WINSPrimaryServer)
            $xNIC [$nIC] [12] = _IsString($objItem.WINSSecondaryServer)
            $xNIC [$nIC] [13] = _IsString($objItem.SettingID)
            $nIC += 1
            $iError = 0
        Next
    Else
        MsgBox(0, "WMI Class Failure!", "WMI Class - 'Win32_NetworkAdapterConfiguration' has encountered an error!")
    EndIf
    If $iError Then
        $xNIC = "Win32_NetworkAdapterConfiguration Class Failure"
    EndIf
    Return SetError($iError, 0, $xNIC)
EndFunc   ;==>_Get_aX
;======================================================================================================================================================
Func _IsString($sString)
    If IsString($sString) Then
        Return $sString
    EndIf
    Return "Not Available"
EndFunc

Func WM_COMMAND($hG, $iMsg, $wPar, $lPar)
    If $wPar = 1 Then
        GUISetState()
        TraySetState(2)
    EndIf
EndFunc

Func _CompatibilityCheck()
    Switch @OSType
        Case "WIN32_NT"
            Switch @OSVersion
                Case "WIN_7" OR "WIN_VISTA"
                    $objValue = '2'
                Case "WIN_XP"
                    Switch @OSServicePack
                        Case "Service Pack 3"
                            $objValue = '2'
                        Case Else
                            $objValue = '9'
                    EndSwitch
                Case "WIN_2000"
                    Return SetError(1, 0, 0)
                Case Else
                    $objValue = '9'
                    Return SetError(2, 0, 0)
            EndSwitch
        Case Else
            $objValue = '9'
            Return SetError(3, 0, 0)
    EndSwitch
EndFunc

Edit:

Added a combobox list ~ tried to read the index of the selection to get specific items from the array and a adapter check.

I can't get either working but i'm sure i wouldnt have to have a 'For..Next' loop each time i want to reference adapter info?

Edit:

_IsString($objItem.DNSServerSearchOrder(1)) ~ gives an error if the adapter is set on 'abtain automatically' although it is attached to your '_IsString' custom function..

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

I will have a look tomorrow and play around with the Example you provided.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

How far off is my script :huh2: ?

I've managed to get the 'ConnectionID's' to set a dynamic menu, and show the right adapter info in the msgbox, but i am still not too sure how i would update the dynamic lists (having it the While loop definately won't work)

Is it possible to have two parameters in the 'ExecQuery()' ~ 'NetConnectionStatus = 2 AND NetConnectionStatus = 0' ?

Edit: the multiple gui's method i used doesn't work while having a dynamic menu that needs 'GUICtrlRead($msg, 1)' to read the menuitem's text..

Edited by katoNkatoNK

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