By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

GetMac address

P: n/a
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
Feb 14 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

Feb 14 '06 #2

P: n/a
Then I suppose I can do a

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

?????

"Shawn" <Te*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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

Feb 14 '06 #3

P: n/a
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

Feb 15 '06 #4

P: n/a
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


Feb 15 '06 #5

P: n/a
Thanks.
--
Dennis in Houston
"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


Feb 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.