First I'd like to thank everyone that has worked on this code! I was looking for something just like this. I have two questions. The first question is: when I run the code I get an array box that opens and when I close that I get the message window with the data. Is there a way to supress the array window and just have the message window open? Also, is it possible to have the text in the message box selectable so it could be copied and pasted? Here is the code I'm working with:
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <Array.au3>
Global $aArray = _IPDetails(), $sData
_ArrayDisplay($aArray)
For $A = 1 To $aArray[0][0]
$sData &= "Description: " & $aArray[$A][0] & @CRLF & "IP Address: " & $aArray[$A][1] & @CRLF & "MAC: " & _
$aArray[$A][2] & @CRLF & "Default Gateway: " & $aArray[$A][3] & @CRLF & "DNS Servers: " & $aArray[$A][4] & @CRLF & @CRLF
Next
$sData = StringTrimRight($sData, 4)
MsgBox(0, "_IPDetails()", $sData)
Func _IPDetails()
Local $iCount = 0
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[1][5] = [[0, 5]]
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$aReturn[0][0] += 1
$iCount += 1
If $aReturn[0][0] <= $iCount + 1 Then
ReDim $aReturn[$aReturn[0][0] * 2][$aReturn[0][1]]
EndIf
$aReturn[$iCount][0] = _IsString($oObjectItem.Description)
$aReturn[$iCount][1] = _IsString($oObjectItem.IPAddress(0))
$aReturn[$iCount][2] = _IsString($oObjectItem.MACAddress)
$aReturn[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0))
$aReturn[$iCount][4] = _IsString(_WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ")) ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking.
Next
ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]]
Return $aReturn
EndIf
Return SetError(1, 0, $aReturn)
EndFunc ;==>_IPDetails
Func _IsString($sString)
If IsString($sString) Then
Return $sString
EndIf
Return "Not Available"
EndFunc ;==>_IsString
Func _WMIArrayToString($aArray, $sDelimeter = "|")
If IsArray($aArray) = 0 Then
Return SetError(1, 0, "Not Available")
EndIf
Local $iUbound = UBound($aArray) - 1, $sString
For $A = 0 To $iUbound
$sString &= $aArray[$A] & $sDelimeter
Next
Return StringTrimRight($sString, StringLen($sDelimeter))
EndFunc ;==>_WMIArrayToString
Any and all help will be greatly appreciated! I'm not a coder but I'm starting to learn.
Thanks,
Tom