Jump to content

Get Ip(s) By Local Area Connection Name.


Recommended Posts

How can I get a list of all IP addresses that are assigned to a particular NIC card?

Is there a DLL that I can use (or maybe COM :) )?

If so how?

Is Autoit capable to do such thing? :(

Thanks

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

oops. wrong thread!

but while I'm here, have you seen the output from:

ipconfig /all

-mu

Yeah thanks, I know about that (I don't need the -all).

This will be the workaround incase no one has an answer.

I want something better than that (like @ipaddress(1,2,3,4)) but these macros are not ordered (random) and their order may change (Ipaddress1 becomes IPaddress2 and ipaddress1 wil be the new IPaddress)

thanks again

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

With ya.

Alternatively, you could rake in the registry,:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards

To find out the serial number of the card, say "B69C652C-76B4-4717-BCC6-DE317498EF40", then go to:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\{B69C652C-76B4-4717-BCC6-DE317498EF40}

For the IP addresses.

Or something like that!

-mu

Link to comment
Share on other sites

With ya.

Alternatively, you could rake in the registry,:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards

To find out the serial number of the card, say "B69C652C-76B4-4717-BCC6-DE317498EF40", then go to:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\{B69C652C-76B4-4717-BCC6-DE317498EF40}

For the IP addresses.

Or something like that!

-mu

Thank you that's exactly what I want. :):(:D

Just one more question. how often does these Reg interies get updated.

@nfwu

your sig was very usefull I already used it in two of my testing scripts

btw you need to fix your post.

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Thank you that's exactly what I want. :):(:D

Just one more question. how often does these Reg interies get updated.

I wouldn't like to say for certain, but stuff in SYSTEM\ControlSet... is usually fairly dynamic,

i.e. it's updated immediately on any system changes.

-mu

Link to comment
Share on other sites

How can I get a list of all IP addresses that are assigned to a particular NIC card?

Is there a DLL that I can use (or maybe COM :) )?

If so how?

Is Autoit capable to do such thing? :(

Thanks

RK

OR,

Try this script generated by SvenP's great port of the Microsoft Scriptomatic Tool which you can find here:

; Generated by AutoIt Scriptomatic

FileDelete ( @TempDir & "\Win32_NetworkAdapterConfiguration.TXT" )
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & '--------------------------------------------------' & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "ArpAlwaysSourceRoute: " & $objItem.ArpAlwaysSourceRoute & @CRLF
      $Output = $Output & "ArpUseEtherSNAP: " & $objItem.ArpUseEtherSNAP & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "DatabasePath: " & $objItem.DatabasePath & @CRLF
      $Output = $Output & "DeadGWDetectEnabled: " & $objItem.DeadGWDetectEnabled & @CRLF
      $strDefaultIPGateway = $objItem.DefaultIPGateway(0)
      $Output = $Output & "DefaultIPGateway: " & $strDefaultIPGateway & @CRLF
      $Output = $Output & "DefaultTOS: " & $objItem.DefaultTOS & @CRLF
      $Output = $Output & "DefaultTTL: " & $objItem.DefaultTTL & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DHCPEnabled: " & $objItem.DHCPEnabled & @CRLF
      $Output = $Output & "DHCPLeaseExpires: " & WMIDateStringToDate($objItem.DHCPLeaseExpires) & @CRLF
      $Output = $Output & "DHCPLeaseObtained: " & WMIDateStringToDate($objItem.DHCPLeaseObtained) & @CRLF
      $Output = $Output & "DHCPServer: " & $objItem.DHCPServer & @CRLF
      $Output = $Output & "DNSDomain: " & $objItem.DNSDomain & @CRLF
      $strDNSDomainSuffixSearchOrder = $objItem.DNSDomainSuffixSearchOrder(0)
      $Output = $Output & "DNSDomainSuffixSearchOrder: " & $strDNSDomainSuffixSearchOrder & @CRLF
      $Output = $Output & "DNSEnabledForWINSResolution: " & $objItem.DNSEnabledForWINSResolution & @CRLF
      $Output = $Output & "DNSHostName: " & $objItem.DNSHostName & @CRLF
      $strDNSServerSearchOrder = $objItem.DNSServerSearchOrder(0)
      $Output = $Output & "DNSServerSearchOrder: " & $strDNSServerSearchOrder & @CRLF
      $Output = $Output & "DomainDNSRegistrationEnabled: " & $objItem.DomainDNSRegistrationEnabled & @CRLF
      $Output = $Output & "ForwardBufferMemory: " & $objItem.ForwardBufferMemory & @CRLF
      $Output = $Output & "FullDNSRegistrationEnabled: " & $objItem.FullDNSRegistrationEnabled & @CRLF
      $strGatewayCostMetric = $objItem.GatewayCostMetric(0)
      $Output = $Output & "GatewayCostMetric: " & $strGatewayCostMetric & @CRLF
      $Output = $Output & "IGMPLevel: " & $objItem.IGMPLevel & @CRLF
      $Output = $Output & "Index: " & $objItem.Index & @CRLF
      $strIPAddress = $objItem.IPAddress(0)
      $Output = $Output & "IPAddress: " & $strIPAddress & @CRLF
      $Output = $Output & "IPConnectionMetric: " & $objItem.IPConnectionMetric & @CRLF
      $Output = $Output & "IPEnabled: " & $objItem.IPEnabled & @CRLF
      $Output = $Output & "IPFilterSecurityEnabled: " & $objItem.IPFilterSecurityEnabled & @CRLF
      $Output = $Output & "IPPortSecurityEnabled: " & $objItem.IPPortSecurityEnabled & @CRLF
      $strIPSecPermitIPProtocols = $objItem.IPSecPermitIPProtocols(0)
      $Output = $Output & "IPSecPermitIPProtocols: " & $strIPSecPermitIPProtocols & @CRLF
      $strIPSecPermitTCPPorts = $objItem.IPSecPermitTCPPorts(0)
      $Output = $Output & "IPSecPermitTCPPorts: " & $strIPSecPermitTCPPorts & @CRLF
      $strIPSecPermitUDPPorts = $objItem.IPSecPermitUDPPorts(0)
      $Output = $Output & "IPSecPermitUDPPorts: " & $strIPSecPermitUDPPorts & @CRLF
      $strIPSubnet = $objItem.IPSubnet(0)
      $Output = $Output & "IPSubnet: " & $strIPSubnet & @CRLF
      $Output = $Output & "IPUseZeroBroadcast: " & $objItem.IPUseZeroBroadcast & @CRLF
      $Output = $Output & "IPXAddress: " & $objItem.IPXAddress & @CRLF
      $Output = $Output & "IPXEnabled: " & $objItem.IPXEnabled & @CRLF
      $strIPXFrameType = $objItem.IPXFrameType(0)
      $Output = $Output & "IPXFrameType: " & $strIPXFrameType & @CRLF
      $Output = $Output & "IPXMediaType: " & $objItem.IPXMediaType & @CRLF
      $strIPXNetworkNumber = $objItem.IPXNetworkNumber(0)
      $Output = $Output & "IPXNetworkNumber: " & $strIPXNetworkNumber & @CRLF
      $Output = $Output & "IPXVirtualNetNumber: " & $objItem.IPXVirtualNetNumber & @CRLF
      $Output = $Output & "KeepAliveInterval: " & $objItem.KeepAliveInterval & @CRLF
      $Output = $Output & "KeepAliveTime: " & $objItem.KeepAliveTime & @CRLF
      $Output = $Output & "MACAddress: " & $objItem.MACAddress & @CRLF
      $Output = $Output & "MTU: " & $objItem.MTU & @CRLF
      $Output = $Output & "NumForwardPackets: " & $objItem.NumForwardPackets & @CRLF
      $Output = $Output & "PMTUBHDetectEnabled: " & $objItem.PMTUBHDetectEnabled & @CRLF
      $Output = $Output & "PMTUDiscoveryEnabled: " & $objItem.PMTUDiscoveryEnabled & @CRLF
      $Output = $Output & "ServiceName: " & $objItem.ServiceName & @CRLF
      $Output = $Output & "SettingID: " & $objItem.SettingID & @CRLF
      $Output = $Output & "TcpipNetbiosOptions: " & $objItem.TcpipNetbiosOptions & @CRLF
      $Output = $Output & "TcpMaxConnectRetransmissions: " & $objItem.TcpMaxConnectRetransmissions & @CRLF
      $Output = $Output & "TcpMaxDataRetransmissions: " & $objItem.TcpMaxDataRetransmissions & @CRLF
      $Output = $Output & "TcpNumConnections: " & $objItem.TcpNumConnections & @CRLF
      $Output = $Output & "TcpUseRFC1122UrgentPointer: " & $objItem.TcpUseRFC1122UrgentPointer & @CRLF
      $Output = $Output & "TcpWindowSize: " & $objItem.TcpWindowSize & @CRLF
      $Output = $Output & "WINSEnableLMHostsLookup: " & $objItem.WINSEnableLMHostsLookup & @CRLF
      $Output = $Output & "WINSHostLookupFile: " & $objItem.WINSHostLookupFile & @CRLF
      $Output = $Output & "WINSPrimaryServer: " & $objItem.WINSPrimaryServer & @CRLF
      $Output = $Output & "WINSScopeID: " & $objItem.WINSScopeID & @CRLF
      $Output = $Output & "WINSSecondaryServer: " & $objItem.WINSSecondaryServer & @CRLF
      $Output = $Output & '=============================================================' & @CRLF & @CRLF

   Next
   ConsoleWrite($Output)
   FileWrite(@TempDir & "\Win32_NetworkAdapterConfiguration.TXT", $Output )
   Run(@SystemDir & "\notepad.exe " & @TempDir & "\Win32_NetworkAdapterConfiguration.TXT" )
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc
Link to comment
Share on other sites

Now I have three solutions regread() , COM and Ipconfig. :)

thanks

If you use the RegRead method, you should be looking at CurrentControlSet rather than ControlSet00x. There can be several ControlSets, but CurrentControlSet is what's being used now, and any changes made there will be reflected in the currently active control set. I don't know where to see which control set is being used.

J

Link to comment
Share on other sites

If you use the RegRead method, you should be looking at CurrentControlSet rather than ControlSet00x. There can be several ControlSets, but CurrentControlSet is what's being used now, and any changes made there will be reflected in the currently active control set. I don't know where to see which control set is being used.

J

Thanks, I will use COM its very simple and fast (some what) then incase com failed I will do Regread() and if that Failed I will Used Ipconfig... if Ipconfig failed I will disable and Enable the NIC...lol

Gotta get this IP

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...