Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to get the mac address of another machine.. one that I'm not running this app from. I have code that is working for getting my own.. but how do I tell it to run this against another computer. Anyone have a code synp i can use to help me along.

 

thanks

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

Here is what I have so far.. this works for the mac address.. but the IPAddress comes up blank. From what I can tell looking around.. that info should be there when you query the Win32_NetworkAdapterConfiguration

 

Dim ms As ManagementScope
       Dim co As ConnectionOptions
       Dim query As ManagementObjectSearcher
       Dim queryCollection As ManagementObjectCollection
       Dim oq As ObjectQuery
       Dim strQuery As String
       Dim mo As ManagementObject


       ms = New ManagementScope("\\" + mvcComputerName + "\root\cimv2", co)
       strQuery = "Select * from Win32_NetworkAdapterConfiguration"
       oq = New ObjectQuery(strQuery)
       query = New ManagementObjectSearcher(ms, oq)

       Try
           queryCollection = query.Get
       Catch ex As Exception
           Throw ex
       End Try

       For Each mo In queryCollection
           mMac = mo("MACAddress").ToString  'This is working
           mIp = mo("IPAddress").ToString  'This isn't
       Next

 

Perhaps now someone might see something that I'm missing

Thanks

Shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Posted
got it figured out.. the ip address. you have bring that back into an array and step through the array.. cause there could be more than 1 ip address per mac..

JvCoach23

VB.Net newbie

MS Sql Vet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...