Link to home
Start Free TrialLog in
Avatar of Corey Scheich
Corey ScheichFlag for United States of America

asked on

Get remote IP or MAC

I am trying to get the IP address or MAC id of a computer on the same lan.  I would like to use .NET calls to do this.  I found the following but it seems to require Admin rights to the computer.  Is there any way to do this without using windows API calls or a High Level Login. I would be alright with the ability to do it with a restricted domain user login though

I found the code here
https://www.experts-exchange.com/questions/21469047/retreive-MAC-address-off-remote-machine.html

    Public Shared Function GetMAC(ByVal ComputerName As String)
        Dim MAC As String = ""
        Try
            Dim query As String = "SELECT * FROM Win32_NetworkAdapterConfiguration"

            Dim searchAddresses As New ManagementObjectSearcher(query)
            Dim ConOpts As New ConnectionOptions()

            ConOpts.Password = "Pswd"
            ConOpts.Username = "Domain\LoginName"
            Dim SearchScope As ManagementScope = New ManagementScope("\\" & ComputerName & "\root\cimv2", ConOpts)
            searchAddresses.Scope = SearchScope

            Dim objColl As ManagementObjectCollection
            objColl = searchAddresses.Get()
            Debug.Print(objColl.ToString)
            For Each Adapter As ManagementObject In objColl
                If Adapter("MacAddress") IsNot Nothing Then
                    MAC = Adapter("MacAddress") '(0)
                End If
            Next
        Catch ex As Exception
            Debug.Print(ex.Message & vbCrLf & vbCrLf & ex.StackTrace)
        End Try

        Return IP
    End Function
ASKER CERTIFIED SOLUTION
Avatar of Corey Scheich
Corey Scheich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial