Solved

Get remote IP or MAC

Posted on 2007-03-23
2
615 Views
Last Modified: 2013-12-17
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
http://www.experts-exchange.com/Programming/Languages/.NET/Q_21469047.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
0
Comment
Question by:Corey2
2 Comments
 
LVL 13

Accepted Solution

by:
Corey2 earned 0 total points
Comment Utility
I found it
Dim HostIP() As System.Net.IPAddress = System.Net.Dns.GetHostEntry(ForComputerName).AddressList
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now