Retrieving a system serial number...

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

Does anyone know how to retrieve the system serial number? I'm writing an
auditing program and need to grab that little bit of info.

Thanks!
 
Terry,

There is not a real serial number, there is sometimes a processor number and
with a computer connected to a LAN or whatever that uses a network adapter,
a Mac address, and probably more numbers, however as far as I have seen not
an always existing unique one.

You can find those starting reading here reading (after that a is a little
sample in this message).

http://msdn.microsoft.com/library/d...ry/en-us/cpref/html/frlrfSystemManagement.asp

http://msdn.microsoft.com/library/d...agementmanagementobjectsearcherclasstopic.asp

It are a lot of collections in collections.

I have not at the moment a sample at hand for those numbers, however see
this sample how to get drive information. I do not know where I got it
anymore.

\\\Add a reference to "System.Management.dll".
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
///

I hope this helps?

Cor
 
Maybe you can use the serialnumber from the next api-call:
Private Declare Function GetVolumeInformation Lib "Kernel32" Alias
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal
lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long,
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long,
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal
nFileSystemNameSize As Long) As Long
 
Hi,

Windows serial number

Dim myReg As RegistryKey = Registry.LocalMachine

Dim MyRegKey As RegistryKey

Dim MyVal As String

MyRegKey = myReg.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion")

MyVal = MyRegKey.GetValue("ProductID")

MyRegKey.Close()



Ken

---------------------------------

Does anyone know how to retrieve the system serial number? I'm writing an
auditing program and need to grab that little bit of info.

Thanks!
 
We use HP/Compaq & IBM machines. Belarc Advisor is able to show the system
serial number of these machines (matches the serial number the vendor puts
on the nameplate). That's what I'm wanting to figure out how to grab...
 
Terry,

I almost forgot to answer you, using the links I showed you and the code
you can use boards, baseboard, serialnumber, than you get the serialnumer of
the baseboard, I do not know if that is the number what is as well what is
at the back of your computers. However the information you can get is so
immense, it is impossible to tell you what it is what without trying.

I hope this helps?

Cor
 
I think I found what I need to get the serial number. It's in the
Win32_BaseBoard WMI Class. Now I need help on how to use it. I tried
this:

Dim w32bb As New ManagementObject("Win32_BaseBoard")

But that give me an exception "specified argument was out of the range
of valid values"

Thanks
 
I found the following code at
http://www.freevbcode.com/ShowCode.asp?ID=2664. Modified it
ever-so-slightly to work in VB.NET. But it retrieves the SerialNumber.

Dim objs As Object
Dim obj As Object
Dim WMI As Object
WMI = GetObject("WinMgmts:")
objs = WMI.InstancesOf("Win32_BaseBoard")
For Each obj In objs
MsgBox(obj.SerialNumber.ToString)
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top