Jump to content
Sign in to follow this  
youtuber

Learning default gateway or modem ip?

Recommended Posts

How can I learn my modem ip adres?

MsgBox(0, "Modem IP", _ComputerGetModemIP())

Func _ComputerGetModemIP()
If @OSArch = "x86" Then
    $hklm = "HKLM"
Else
    $hklm = "HKLM64"
EndIf
 $aReadModemIP = RegRead($hklm & '\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\{FB281152-E073-454A-B7A3-0DD078663751}', 'DhcpDefaultGateway')
Return  $aReadModemIP
EndFunc

 

Share this post


Link to post
Share on other sites

If the modem is your default gateway, you can do this:

#include <Array.au3>

Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]]
Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    For $NIC In $oNics
        _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName)
    Next

_ArrayDisplay($aIPs)

If it is not, we'll have to do some sniffing on the network.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

You'll have to try it and see if you get what you're expecting; my main machine is a 2012 server with 4 NICs, so it would not be correct for me.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

Understood thanks.
I want to use it as a function I do not want an error when I do not have internet for how to do it?

_GetdefaultGateway()

Func _GetdefaultGateway()
Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]]
Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    For $NIC In $oNics
        _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName)
    Next
    Return $aIPs[1][1]
    if @error Then
        Return False
        EndIf
EndFunc

fsdf

Share this post


Link to post
Share on other sites

Is it right to prevent an error? help please

Func _GetdefaultGateway()
Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]]
Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    If IsObj($oNics) Then
    For $NIC In $oNics
        _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName)
    Next
Return $aIPs[1][1]
    Else
     MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration")
    EndIf
EndFunc

 

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...