LWC Posted May 10, 2019 Posted May 10, 2019 (edited) I have multiple network adapters but only one is actually connected. I thus use @IPAddress1 in my scripts whereas @IPAddress2-4 return 0.0.0.0 But recently I've installed the VirtualBox emulator and it took over @IPAddress1 which means my real connection is now @IPAddress2. Why is that? Is there a way to make AutoIt skip to @IPAddress2 if @IPAddress1 is used by an emulator? In the attached screenshot it's temporarily disabled so I can revive my scripts which all already use @IPAddress1. Edited November 2, 2024 by LWC Unlinked to solution now that it's automated linked
supraaxdd Posted May 10, 2019 Posted May 10, 2019 Try and look around in this post, you may find something useful. I'm not the type of person to deal with these, so I will just supply you with the link and maybe the guide will help you change or possibly explain how it works... Tell me if you find anything. Regards, Supra
argumentum Posted May 10, 2019 Posted May 10, 2019 pull data from ipconfig, the one that match the 3 first octets of the gateway is the one. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
TheDcoder Posted May 11, 2019 Posted May 11, 2019 If you want the external IP address which is visible to other computers/servers, you can use the _GetIP function: _GetIP EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
Solution LWC Posted May 11, 2019 Author Solution Posted May 11, 2019 (edited) TCPNameToIP(@ComputerName) actually matches @IPAddress1 (the emulated one), not @IPAddress2 (the actual internal one), so it doesn't change anything. _GetIP() is not relevant as I need the right internal address, not an external one. So I've ended up successfully using the following code, which finds the first adapter which has a gateway, as it seems like emulated ones don't have gateways. But I do wish @IPAddress1-4 would have just given priority to non emulated addresses over emulated ones. $internal_not_emulated_ip_address=_GetGateway()[0] Func _GetGateway() ; Based on: ; Rajesh V R ; v 1.0 01 June 2009 ; use the adapter name as seen in the network connections dialog... Const $wbemFlagReturnImmediately = 0x10 Const $wbemFlagForwardOnly = 0x20 Local $colNICs="", $NIC, $strQuery, $objWMIService $strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration" $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colNICs = $objWMIService.ExecQuery($strQuery, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) Local $output[2] If IsObj($colNICs) Then For $NIC In $colNICs if isstring($NIC.DefaultIPGateway(0)) then $output[0] = $NIC.IPAddress(0) $output[1] = $NIC.DefaultIPGateway(0) ExitLoop endif Next Else Return SetError(-1, 0, "No WMI Objects Found for class: Win32_NetworkAdapterConfiguration") EndIf Return $output EndFunc Edited November 2, 2024 by LWC Rephrased argumentum 1
supraaxdd Posted May 11, 2019 Posted May 11, 2019 (edited) Did the site I sent at the beginning help in any way? I'm just curious Regards, Supra Edited May 11, 2019 by supraaxdd
LWC Posted May 11, 2019 Author Posted May 11, 2019 Just now, supraaxdd said: Did the site I sent at the beginning help in any way? I'm just curious Oh sorry, not really, as it seems to be about internal settings within VirtualBox, which affect the guest virtual machines, not the host.
supraaxdd Posted May 11, 2019 Posted May 11, 2019 That's all good, as long as you resolved the problem! I'm not into these things, and I just wanted to see if I can help with an article about it... Good luck in the future! Regards, Supra
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