Get Bios Serial Number In Vb6
Visual Basic.NET; How to get machine serial number? Hi there, does anyone have any idea how to read the PC's serial number from the BIOS? Any help would be very much appreciated. Just to clarify, I am talking about the hardware serial number of the PC itself, not (i repeat not) software keys of any description!
I have some coding that works on Windows XP Pro, Home, and CE but not on Windows Embedded. Cirrus jet specs.
The code below detects and reports multiple Hardware serial number. The code was tested and working on Windows XP Pro, Home, and CE but does not work on Microsoft Windows Embedded.
I also understand that I need WMI installed on the PC before such code will operate, but I have already done so.
Private Sub Command0_Click()
''Detecting the Serial Number of the Hard Drive
MsgBox CreateObject('Scripting.FileSystemObject').GetDrive('C:').SerialNumber
''Detecting the serial numbers of the CPU's
Dim cimv2, PInfo, PItem ' no idea what to declare these as
Dim PubStrComputer As String
PubStrComputer = '.'
Set cimv2 = GetObject('winmgmts:' & PubStrComputer & 'rootcimv2')
Set PInfo = cimv2.ExecQuery('Select * From Win32_Processor')
For Each PItem In PInfo
MsgBox (PItem.Name & ' Id: ' & PItem.ProcessorId)
Next PItem
''Detecting BIOS Information
Dim objWMIService
Dim colItems
Dim objItem
Dim strMsg
Set objWMIService = GetObject('winmgmts://./root/cimv2')
Set colItems = objWMIService.ExecQuery('Select * from Win32_BIOS where PrimaryBIOS = true', , 48)
Serial Number Lookup
For Each objItem In colItems
strMsg = strMsg _
& ' BIOS Name : ' & objItem.Name & vbCrLf _
& ' Version : ' & objItem.Version & vbCrLf _
& ' Manufacturer : ' & objItem.Manufacturer & vbCrLf _
& ' Serial Number : ' & objItem.SerialNumber & vbCrLf _
& ' SMBIOS Version : ' & objItem.SMBIOSBIOSVersion & vbCrLf
Next
MsgBox strMsg
''Detecting Motherboard Serial NUmber
Dim objs As Object
Dim obj As Object
Dim WMI As Object
Dim sAns As String
Set WMI = GetObject('WinMgmts:')
Set objs = WMI.InstancesOf('Win32_BaseBoard')
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & ','
Next
MsgBox sAns
End Sub