BruceCopperField Posted August 6, 2009 Share Posted August 6, 2009 What would the @IPAddress[1-4] returns if I have > 4 network adapters. The reasons I got >4 is that first I have installed some loopback drivers and then installed VMWare. VMWare installed 2-3 virtual adapters of its own to the list. Physically, I only got 1 network adapter and is connecting through PPPoE. I need to check if I have login to the network by verifying that I have got a valid ip address assigned by my ISP. But now, having so many adapters how can i be sure which of the @IPAddress's to use and in particular when there're >4 adapters would the physical adapter be actually available in one of them? Link to comment Share on other sites More sharing options...
99ojo Posted August 6, 2009 Share Posted August 6, 2009 Global $ipaddress _GetNetworkadapterIP () MsgBox (0,"", $ipaddress) Func _GetNetworkadapterIP () $strComputer = "Localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration") For $objItem In $colItems If StringInStr ($objitem.Description, "VMWare") Then; this is my physical Adapter change it to yours $ipaddress = $objitem.IPAddress(0) ; e.g. RealTek RTL8139, you don't need the whole descrition EndIf Next EndFunc ;-)) Stefan Link to comment Share on other sites More sharing options...
FreeBeing Posted August 6, 2009 Share Posted August 6, 2009 Global $ipaddress _GetNetworkadapterIP () MsgBox (0,"", $ipaddress) Func _GetNetworkadapterIP () $strComputer = "Localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration") For $objItem In $colItems If StringInStr ($objitem.Description, "VMWare") Then; this is my physical Adapter change it to yours $ipaddress = $objitem.IPAddress(0) ; e.g. RealTek RTL8139, you don't need the whole descrition EndIf Next EndFunc ;-)) Stefan Thanks, good script >_< Link to comment Share on other sites More sharing options...
jvanegmond Posted August 6, 2009 Share Posted August 6, 2009 Global $ipaddress _GetNetworkadapterIP () MsgBox (0,"", $ipaddress) Func _GetNetworkadapterIP () $strComputer = "Localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration") For $objItem In $colItems If StringInStr ($objitem.Description, "VMWare") Then; this is my physical Adapter change it to yours $ipaddress = $objitem.IPAddress(0) ; e.g. RealTek RTL8139, you don't need the whole descrition EndIf Next EndFunc ;-)) Stefan Here's so you don't have to modify the function. Global $ipaddress _GetNetworkadapterIP ("VMWare") MsgBox (0,"", $ipaddress) Func _GetNetworkadapterIP ($sDesc) $strComputer = "Localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration") For $objItem In $colItems If StringInStr ($objitem.Description, $sDesc) Then; this is my physical Adapter change it to yours $ipaddress = $objitem.IPAddress(0) ; e.g. RealTek RTL8139, you don't need the whole descrition EndIf Next EndFunc github.com/jvanegmond 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