Sign in to follow this  
Followers 0
BruceCopperField

Having More Than 4 Network Adapters

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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 >_<

Share this post


Link to post
Share on other sites

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

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  
Followers 0