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

Display IP Address

$
0
0
AutoIt         
#include <Array.au3> #include <Constants.au3> Local $aArray = _IPDetails() If @error = 0 Then     Local $sData = 'Your IP Address: ' & $aArray[1] & @CRLF & _             'Your Gateway Address: ' & $aArray[3] & @CRLF & _             'You DNS Servers: ' & $aArray[4]     MsgBox($MB_SYSTEMMODAL, '', $sData) EndIf _ArrayDisplay($aArray) Func _IPDetails()     Local $oWMIService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & '.' & '\root\cimv2')     Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True', 'WQL', 0x30), $aReturn[5] = [0]     If IsObj($oColItems) Then         For $oObjectItem In $oColItems             If $oObjectItem.IPAddress(0) == @IPAddress1 Then                 $aReturn[0] = 4                 $aReturn[1] = $oObjectItem.IPAddress(0)                 $aReturn[2] = $oObjectItem.MACAddress                 $aReturn[3] = $oObjectItem.DefaultIPGateway(0)                 $aReturn[4] = _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), ', ') ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking.             EndIf         Next     EndIf     Return SetError($aReturn[0] = 0, 0, $aReturn) EndFunc   ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = '|')     Local $sString = 'Not Available'     If UBound($aArray) Then         For $i = 0 To UBound($aArray) - 1             $sString &= $aArray[$i] & $sDelimeter         Next         $sString = StringTrimRight($sString, StringLen($sDelimeter))     EndIf     Return $sString EndFunc   ;==>_WMIArrayToString

This is the code I found on AutoIT Forum, its worked on Wired but not wireless. Could anyone help me on this, please? 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



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