littleclown Posted December 22, 2009 Share Posted December 22, 2009 Hello. I need to get ALL local IP addresses, but without using @IPAddressX (sometimes this just can't "see" IPs). On some PCs I have more than 4 network adapters. It can be an array, it can be a list - no problem. Thanks in advanced. Link to comment Share on other sites More sharing options...
enaiman Posted December 22, 2009 Share Posted December 22, 2009 ipconfig /all All you have to do after that is to extract the info from the data returned. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
littleclown Posted December 23, 2009 Author Share Posted December 23, 2009 Yes, this is the way that I currently use, but I wonder is there some more.. clear way to do it. Thanks anyway . Link to comment Share on other sites More sharing options...
99ojo Posted December 23, 2009 Share Posted December 23, 2009 Hi, WMI could be your friend..... #include <array.au3> ; only needed for _Arraydisplay Global $arnwadap [1] [2] ; Global array for network adapter and ip _getnetworkadapter () _ArrayDisplay ($arnwadap) ; WMI get only Adapter with ip settings ; If WMI fail or no adapter with ip settings Return 0 Func _getnetworkadapter () $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $found = False $strComputer = "localhost" $count = 0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If StringInStr ($objItem.IPAddress(0), ".") <> 0 Then ReDim $arnwadap [$count + 1] [2] $arnwadap [0] [0] = $objItem.Caption $arnwadap [0] [1] = $objItem.IPAddress(0) $count += 1 $found = True EndIf Next If Not $found Then Return 0 Else Return 0 EndIf EndFunc ;-)) Stefan Link to comment Share on other sites More sharing options...
littleclown Posted December 23, 2009 Author Share Posted December 23, 2009 Thanks for the script, but its not work for me. I have 2 Vmware network adapters with static IPs One not connected adapter And one physical adapter working on DCHP The result of this script is just information of one of the virtual NICs and 3 blank lines. Thanks for the help anyway. Link to comment Share on other sites More sharing options...
99ojo Posted December 23, 2009 Share Posted December 23, 2009 (edited) Hi, shame on me........ This should work, tested with 2 VMWare Adapter static IP and one physical NIC with DHCP: #include <array.au3> ; only needed for _Arraydisplay Global $arnwadap [1] [2] ; Global array for network adapter and ip _getnetworkadapter () _ArrayDisplay ($arnwadap) ; WMI get only Adapter with ip settings ; If WMI fail or no adapter with ip settings Return 0 Func _getnetworkadapter () $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $found = False $strComputer = "localhost" $count = 0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If StringInStr ($objItem.IPAddress(0), ".") <> 0 Then ReDim $arnwadap [$count + 1] [2] $arnwadap [$count] [0] = $objItem.Caption ;corrected to $count $arnwadap [$count] [1] = $objItem.IPAddress(0) ;corrected to $count $count += 1 $found = True EndIf Next Else Return 0 EndIf If Not $found Then Return 0 EndFunc ;-)) Stefan Edited December 23, 2009 by 99ojo Link to comment Share on other sites More sharing options...
littleclown Posted December 23, 2009 Author Share Posted December 23, 2009 Great script! Thank you for the fast reply and happy holidays. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now