Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Arrays making my head hurt

$
0
0

Hi Guys

 

Am hoping someone here will probably solve this problem I can't seem to get my head around.

 

I basically want to get the NetconnectionID, MACAddress IPAddress(0) and IPAddress(1) all into the same array making sure that the IP addresses match the MACaddress.

 

 

Heres the code ive managed to come up with which creates two seperate arrays but I just dont know how to combine them into a single array. 

AutoIt         
Func _GetNetworkInfo()   Local $sArray1 [1] [4] Local $sArray2 [1] [4]   $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $sWMIService = "winmgmts:\\.\root\CIMV2" $objWMIService = ObjGet($sWMIService)   If IsObj($objWMIService) Then   $colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter " _ & "where NetConnectionStatus=2", "WQL", _                                               $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems1) Then For $objItem1 in $colItems1 ReDim $sArray1 [UBound($sArray1) + 1] [4] $sArray1 [UBound($sArray1) - 1] [0] = $objItem1.NetConnectionID $sArray1 [UBound($sArray1) - 1] [1] = $objItem1.MACAddress Next Else MsgBox(16, "Error", "Failed to get Win32_NetworkAdapter") EndIf _ArrayDisplay($sArray1) $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration " _ & "where IPEnabled=TRUE", "WQL", _                                               $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems2) Then For $objItem2 in $colItems2 ReDim $sArray2 [UBound($sArray2) + 1] [4] $sArray2 [UBound($sArray2) - 1] [1] = $objItem2.MACAddress $sArray2 [UBound($sArray2) - 1] [2] = $objItem2.IPAddress(0) $sArray2 [UBound($sArray2) - 1] [3] = $objItem2.IPAddress(1) Next Else MsgBox(16, "Error", "Failed to get Win32_NetworkAdapterConfiguration") EndIf _ArrayDisplay($sArray2) Else MsgBox(4096, "Error", "Failed to connect to WMI at: " & $sWMIService) EndIf Return EndFunc

I did try and create a script that did the same as this vbs code I found but I couldnt seem to get it working.

For Each objNetAdapter in colNetAdapters strMACAddress = objNetAdapter.MACAddress Next Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration") For Each objItem in colItems If objItem.MACAddress = strMACAddress Then strIPAddress = objNetAdapter.IPAddress

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>