Home All Groups Group Topic Archive Search About
Author
14 Feb 2006 8:09 PM
Jason
In vb.net how do I get the mac address of my Nic card.

There are 6 total nic's in my pc, the mac that I'm looking for belongs to
the network adapter that
has the description  Intel(R) PRO/1000 MT Network Connection - Packet
Scheduler Miniport

Any ideas?
Thanks

Author
14 Feb 2006 8:59 PM
Shawn
You could use WMI and do something similar to the following:

Private Function MacAttack() As String
        Dim scope As ManagementScope = New
ManagementScope(ManagementPath.DefaultPath)
        Dim query As SelectQuery = New
SelectQuery("Win32_NetworkAdapterConfiguration")
        ' this query returns all properties of the class
        Dim searcher As ManagementObjectSearcher = New
ManagementObjectSearcher(scope, query)
        Dim mo As New ManagementObject
        For Each mo In searcher.Get()
            If (mo.Item("IPEnabled").ToString) = True.ToString Then
'Environment.UserName Then
                'MsgBox(mo.Item("MacAddress").ToString)
                Try
                    MacAttack = (mo.Item("MacAddress").ToString)
                Catch ex As Exception

                End Try
            End If
        Next
    End Function
Author
14 Feb 2006 9:45 PM
Jason
Then I suppose I can do a

    ("Select * from Win32_NetworkAdapterConfiguration Where Description =
"Intel(R) PRO/1000 MT Network Connection - Packet
Scheduler Miniport")

?????

Show quoteHide quote
"Shawn" <TechniSh***@gmail.com> wrote in message
news:1139950745.672398.269440@o13g2000cwo.googlegroups.com...
> You could use WMI and do something similar to the following:
>
> Private Function MacAttack() As String
>        Dim scope As ManagementScope = New
> ManagementScope(ManagementPath.DefaultPath)
>        Dim query As SelectQuery = New
> SelectQuery("Win32_NetworkAdapterConfiguration")
>        ' this query returns all properties of the class
>        Dim searcher As ManagementObjectSearcher = New
> ManagementObjectSearcher(scope, query)
>        Dim mo As New ManagementObject
>        For Each mo In searcher.Get()
>            If (mo.Item("IPEnabled").ToString) = True.ToString Then
> 'Environment.UserName Then
>                'MsgBox(mo.Item("MacAddress").ToString)
>                Try
>                    MacAttack = (mo.Item("MacAddress").ToString)
>                Catch ex As Exception
>
>                End Try
>            End If
>        Next
>    End Function
>
Author
15 Feb 2006 1:09 AM
Dennis
Will this also retrieve wireless ethernet card MAC's?
--
Dennis in Houston


Show quoteHide quote
"Shawn" wrote:

> You could use WMI and do something similar to the following:
>
> Private Function MacAttack() As String
>         Dim scope As ManagementScope = New
> ManagementScope(ManagementPath.DefaultPath)
>         Dim query As SelectQuery = New
> SelectQuery("Win32_NetworkAdapterConfiguration")
>         ' this query returns all properties of the class
>         Dim searcher As ManagementObjectSearcher = New
> ManagementObjectSearcher(scope, query)
>         Dim mo As New ManagementObject
>         For Each mo In searcher.Get()
>             If (mo.Item("IPEnabled").ToString) = True.ToString Then
> 'Environment.UserName Then
>                 'MsgBox(mo.Item("MacAddress").ToString)
>                 Try
>                     MacAttack = (mo.Item("MacAddress").ToString)
>                 Catch ex As Exception
>
>                 End Try
>             End If
>         Next
>     End Function
>
>
Author
15 Feb 2006 3:49 PM
Shawn
Yes


Dennis wrote:
Show quoteHide quote
> Will this also retrieve wireless ethernet card MAC's?
> --
> Dennis in Houston
>
>
> "Shawn" wrote:
>
> > You could use WMI and do something similar to the following:
> >
> > Private Function MacAttack() As String
> >         Dim scope As ManagementScope = New
> > ManagementScope(ManagementPath.DefaultPath)
> >         Dim query As SelectQuery = New
> > SelectQuery("Win32_NetworkAdapterConfiguration")
> >         ' this query returns all properties of the class
> >         Dim searcher As ManagementObjectSearcher = New
> > ManagementObjectSearcher(scope, query)
> >         Dim mo As New ManagementObject
> >         For Each mo In searcher.Get()
> >             If (mo.Item("IPEnabled").ToString) = True.ToString Then
> > 'Environment.UserName Then
> >                 'MsgBox(mo.Item("MacAddress").ToString)
> >                 Try
> >                     MacAttack = (mo.Item("MacAddress").ToString)
> >                 Catch ex As Exception
> >
> >                 End Try
> >             End If
> >         Next
> >     End Function
> >
> >
Author
16 Feb 2006 1:04 AM
Dennis
Thanks.
--
Dennis in Houston


Show quoteHide quote
"Shawn" wrote:

> Yes
>
>
> Dennis wrote:
> > Will this also retrieve wireless ethernet card MAC's?
> > --
> > Dennis in Houston
> >
> >
> > "Shawn" wrote:
> >
> > > You could use WMI and do something similar to the following:
> > >
> > > Private Function MacAttack() As String
> > >         Dim scope As ManagementScope = New
> > > ManagementScope(ManagementPath.DefaultPath)
> > >         Dim query As SelectQuery = New
> > > SelectQuery("Win32_NetworkAdapterConfiguration")
> > >         ' this query returns all properties of the class
> > >         Dim searcher As ManagementObjectSearcher = New
> > > ManagementObjectSearcher(scope, query)
> > >         Dim mo As New ManagementObject
> > >         For Each mo In searcher.Get()
> > >             If (mo.Item("IPEnabled").ToString) = True.ToString Then
> > > 'Environment.UserName Then
> > >                 'MsgBox(mo.Item("MacAddress").ToString)
> > >                 Try
> > >                     MacAttack = (mo.Item("MacAddress").ToString)
> > >                 Catch ex As Exception
> > >
> > >                 End Try
> > >             End If
> > >         Next
> > >     End Function
> > >
> > >
>
>