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 enable me get
the serial number of the motherboard or harddrive on a
given system but no luck so far. Can any one out there
help me.
 
Hi,

Add a reference to system.management.dll.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_LogicalDisk'")

moReturn = moSearch.Get

For Each mo In moReturn

Dim VolumeName As String = mo("Volumename")

Dim SerialNumber As String = mo("Volumeserialnumber")

Dim strOut As String = String.Format("{0} - {1}", VolumeName, SerialNumber)

Debug.WriteLine(strOut)

Next

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

moReturn = moSearch.Get

For Each mo In moReturn

Debug.WriteLine(mo("ProcessorID"))

Next



Ken
 
* "Abubakar said:
I have been trying to write a code that will enable me get
the serial number of the motherboard or harddrive on a
given system but no luck so far. Can any one out there
help me.

Harddisk volume number:

Add a reference to "System.Management.dll", then import the namespace
'System.Management' and use this code to get info about the volume
(including the serial number):

\\\
Dim disk As New ManagementObject( _
"Win32_LogicalDisk.DeviceID=""C:""" _
)
Dim diskProperty As PropertyData
For Each diskProperty In disk.Properties
Console.WriteLine( _
"{0} = {1}", _
diskProperty.Name, _
diskProperty.Value _
)
Next diskProperty
///
 
Addendum:

If you want to use WMI, have a look at the classes 'Win32_DiskDrive' and
'Win32_BaseBoard'.
 
Herr Herfried,
If you want to use WMI, have a look at the classes 'Win32_DiskDrive' and
'Win32_BaseBoard'.

I have tried on different ways to get information from the
System.Management.ManagementObject

For the operating system classes it is no problem for me, but for the
Hardware classes it was impossible, maybe can you help me how to do that, as
example the number from the mainboard?

Corrina.
 
* "Corrina said:
I have tried on different ways to get information from the
System.Management.ManagementObject

For the operating system classes it is no problem for me, but for the
Hardware classes it was impossible, maybe can you help me how to do that, as
example the number from the mainboard?

Not all mainboards provide a serial number.

A C# implementation for reading the serial number of the mainboard can
be found here:


LOL
 
Hallo Herfried,

Got it,

Now I know what it was.

For your information, if you did know it, than is nothing wrong I tell it
The collection of a let say WMI Win32xx_ can exist itself again from a
collection.
But that is only if there are more collections from that collection.
Something the same as the favorites.

Anyway thanks with this I had it in 30 minutes all done, was long been busy
with it, I just missed the handle.

(I had almost all, just that it was a single collection with properties,
that was where I went blind)

Thanks

Corrina
 
Back
Top