VB.NET - System imformation

Asked By siva narayana on 11-Jan-11 05:53 AM
How to read system MAC id / serial number in vb.net

Reagds
Siva
murali k replied to siva narayana on 11-Jan-11 06:06 AM
hi frnd

 use this link it may help u

http://www.winsim.com/diskid32/diskid32.html

http://www.devasp.net/net/articles/display/150.html

http://thedailyreviewer.com/dotnet/view/hdd-serial-number-and-mac-address-in-vb-6-101686495

http://www.vbforums.com/showthread.php?t=508069
murali k replied to siva narayana on 11-Jan-11 06:06 AM
hi frnd

 use this link it may help u

http://www.winsim.com/diskid32/diskid32.html

http://www.devasp.net/net/articles/display/150.html

http://thedailyreviewer.com/dotnet/view/hdd-serial-number-and-mac-address-in-vb-6-101686495

http://www.vbforums.com/showthread.php?t=508069
Anoop S replied to siva narayana on 11-Jan-11 07:59 AM
You can use this code to find MAC id

Public Function GetMACAddress() As String
  Dim mc As New ManagementClass("Win32_NetworkAdapterConfiguration")
  Dim moc As ManagementObjectCollection = mc.GetInstances()
 
  Dim MACAddress As String = [String].Empty
  For Each mo As ManagementObject In moc
    If MACAddress = [String].Empty Then
      ' only return MAC Address from first card
      If CBool(mo("IPEnabled")) = True Then
 
        MACAddress = mo("MacAddress").ToString()
      End If
    End If
    mo.Dispose()
  Next
 
  MACAddress = MACAddress.Replace(":", "")
  Return MACAddress
End Function


Reena Jain replied to siva narayana on 11-Jan-11 08:27 AM
hi siva,

here is the code for you

Add Reference to System.Management.dll.
 
Add Imports system.Management at the top of your source code.
 
Code Block
 
Imports System.Management
 
Module Module1
 
  Sub Main()
 
    Dim oConn As ConnectionOptions = New ConnectionOptions
 
    oConn.Username = "Administrator"
 
    oConn.Password = "password"
 
    Dim oMs As System.Management.ManagementScope = New System.Management.ManagementScope("\\machineID", oConn)
 
    Dim oQuery As System.Management.ObjectQuery = New System.Management.ObjectQuery("select SerialNumber from Win32_BaseBoard")
 
    Dim oSearcher As ManagementObjectSearcher = New ManagementObjectSearcher(oMs, oQuery)
 
    Dim oReturnCollection As ManagementObjectCollection = oSearcher.Get
 
    For Each oReturn As ManagementObject In oReturnCollection
 
      Console.WriteLine(("Serial Number : " + oReturn("SerialNumber").ToString))
 
    Next
 
    Console.ReadLine()
 
  End Sub
 
End Module
 
Reference: Win32_MotherboardDevice Class

hope this will help you