youtuber Posted August 10, 2017 Posted August 10, 2017 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
Moderators JLogan3o13 Posted August 10, 2017 Moderators Posted August 10, 2017 Do you want your modem's IP on the internal network? Or your external-facing IP address? "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!
youtuber Posted August 10, 2017 Author Posted August 10, 2017 External-facing IP address no problem #include <Inet.au3> #include <MsgBoxConstants.au3> Local $sPublicIP = _GetIP() MsgBox($MB_SYSTEMMODAL, "", "Your external IP address is: " & $sPublicIP) I just want a modem ip address
Moderators JLogan3o13 Posted August 10, 2017 Moderators Posted August 10, 2017 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. youtuber 1 "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!
youtuber Posted August 10, 2017 Author Posted August 10, 2017 Is this correct? Thank you MsgBox($MB_SYSTEMMODAL, "", "Your Default gateway IP address is: " & $aIPs[1][1])
Moderators JLogan3o13 Posted August 10, 2017 Moderators Posted August 10, 2017 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. youtuber 1 "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!
youtuber Posted August 10, 2017 Author Posted August 10, 2017 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
youtuber Posted August 11, 2017 Author Posted August 11, 2017 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
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