Getting either harddrive or motherboard serial number

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

I have been trying to write a code that will give me the
serial number of a harddrive or that of a motherboard, but
i don't seem to get it right.
Do anybody out there have any idea?
 
You need to use WMI check MSDN at this link:

http://msdn.microsoft.com/library/d.../en-us/wmisdk/wmi/win32_motherboarddevice.asp

using System.Management;

//Connection credentials to the remote computer - not needed if the logged
in account has access
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "Administrator";
oConn.Password = "";

System.Management.ManagementScope oMs = new
System.Management.ManagementScope(\\MachineID, oConn);

System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select SerialNumber from Win32_BaseBoard");

ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);

ManagementObjectCollection oReturnCollection = oSearcher.Get();

foreach( ManagementObject oReturn in oReturnCollection )
{
Console.WriteLine("Serial Number : " +
oReturn["SerialNumber"].ToString());
}

Hope this helps

Ian
 
I hope that this worked for you.

in message
You need to use WMI check MSDN at this link:

http://msdn.microsoft.com/library/d.../en-us/wmisdk/wmi/win32_motherboarddevice.asp

using System.Management;

//Connection credentials to the remote computer - not needed if the logged
in account has access
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "Administrator";
oConn.Password = "";

System.Management.ManagementScope oMs = new
System.Management.ManagementScope(\\MachineID, oConn);

System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select SerialNumber from Win32_BaseBoard");

ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);

ManagementObjectCollection oReturnCollection = oSearcher.Get();

foreach( ManagementObject oReturn in oReturnCollection )
{
Console.WriteLine("Serial Number : " +
oReturn["SerialNumber"].ToString());
}

Hope this helps

Ian


Abubakar said:
I have been trying to write a code that will give me the
serial number of a harddrive or that of a motherboard, but
i don't seem to get it right.
Do anybody out there have any idea?
 
Back
Top