• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

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

    Public Shared Function GetMAC(ByVal ComputerName As String)
        Dim MAC As String = ""
            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()
            For Each Adapter As ManagementObject In objColl
                If Adapter("MacAddress") IsNot Nothing Then
                    MAC = Adapter("MacAddress") '(0)
                End If
        Catch ex As Exception
            Debug.Print(ex.Message & vbCrLf & vbCrLf & ex.StackTrace)
        End Try

        Return IP
    End Function
Corey Scheich
Corey Scheich
1 Solution
Corey ScheichDeveloperAuthor Commented:
I found it
Dim HostIP() As System.Net.IPAddress = System.Net.Dns.GetHostEntry(ForComputerName).AddressList
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now