View Single Post
  #16  
Old March 18th 18, 02:21 PM posted to alt.comp.os.windows-10
Mayayana
external usenet poster
 
Posts: 6,438
Default SSDs serial No in BIOS.

"Andy Burns" wrote

| from within a cmd.exe window, try
|
| wmic.exe diskdrive get serialnumber
|

It's not clear to me how a serial number is
going to help Peter Jason. Serial numbers are mostly
for commercial use. If he doesn't know which disk
he cloned he could always put piece of tape on
one of them, no?

In any case....
What you're doing is the same thing as what Garry
is doing. He's using WMI via script. You're using a WMI
wrapper applet for command line. Both are using WMI.
(Most 3rd party system info utilities also use WMI. So
it's worthwhile getting it from the horse's mouth.)

The only difference is that he was listing
logical disks (partitions) rather than physical
disks. For physical disks you can get all kinds
of info. SerialNumber is available after XP. If
one needs to deal with XP then DeviceID can
be used. (SCSIPort might also be useful, but
on my current machine it just returns 0.)

Either way, whatever you get will be
the same via either method. wmic.exe is just
a wrapper to allow people using PowerShell
to access WMI. For anyone who knows scripting
or software programming, those methods will
be a lot easier and far more flexible than command
line. wmic is a kind of training wheels method to
get single, specific properties without needing
to learn about WMI. It's one of the many things
designed for IT people so that they can do their
job using one-line incantations that can be shared
and found online, without having to learn the
whole system.

For anyone who wants to use WMI.....

There's a help file in the Win32 SDK that's
indispensible because the methods and properties
are vast and the object model is stunningly bad in
its design. (Whenever I work with WMI I use a
combination of the help file and previous scripts
I've written. The syntax is tragically non-intuitive,
so I find it easier to just adapt things I've written
before.

As can be seen from your sample, wmic is not
designed in accord with WMI, so while your method
is good once you know it, you'll need a wmic reference
in order to use it for anything more than a snippet
here or there. Specifically in this case, WMI has no
"diskdrive" object. That's a corruption introduced
by wmic.exe.

(Corruption may seem a strong word, but designing
things that way confuses people and makes the job
harder for everyone. The object in WMI is
Win32_DiskDrive. Admittedly, that's a sorry excuse for
an object name... No one should ever have to type
underscores and the "Win32" part is superfluous.... but
MS screwed it up and there's no going back. Yet with
wmic they apparently decided to simplify it. But since
wmic is not following the WMI object model, no amount
of experience with WMI will allow one to predict the
correct call to make to wmic for any specific info!
That's much worse than re-using bad object names.
It's like writing a cookbook and deciding to rename
recipes, like renaming Baked Alaska to Flaming Ice Cream.
No one will know to look up Flaming Ice Cream. And
everyone will be confused when their guests are
served Baked Alaska under a pseudonym.)

The following VBScript shows some of the properties
available from Win32_DiskDrive. Copy to Notepad,
save as something.vbs, double-click to see a report:

Dim WMI, Col, Ob, s2, s3
On Error Resume Next
Set WMI = GetObject("WinMgmts:")
Set Col = WMI.ExecQuery("Select * from Win32_DiskDrive")
s2 = "Drives:" & vbCrLf & vbCrLf
For Each Ob in Col
s2 = s2 & "Description: " & Ob.Description & vbCrLf
s2 = s2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf
s2 = s2 & "Model: " & Ob.Model & vbCrLf
s2 = s2 & "InterfaceType: " & Ob.InterfaceType & vbCrLf
s2 = s2 & "MediaType: " & Ob.MediaType & vbCrLf
s2 = s2 & "DeviceID: " & Ob.DeviceID & vbCrLf
'-- This next only available on Vista+
s2 = s2 & "SerialNumber: " & Ob.SerialNumber & vbCrLf
s2 = s2 & "Number of Win Partitions: " & Ob.Partitions & vbCrLf
s3 = CStr(Ob.Size)
If Len(s3) 9 Then
s3 = Left(s3, (len(s3) - 9))
s2 = s2 & "Size (GB): " & s3
End If
s2 = s2 & vbCrLf & vbCrLf
Next
Set Col = Nothing
Set WMI = Nothing
MsgBox s2

'---------------------------------------
For what it's worth, here's one I use to do a quick survey of
hardware on a system. It writes a report to C:\Sysinfo.txt:
'----------------------------------


Dim WMI, Col, Ob, S2, i2, s3, sFil, sBul, sLine

'-- path to save data. ------------------
sFil = "C:\Sysinfo.txt"

sBul = " " & Chr(149) & " "
sLine = vbCrLf & "_____________________________________________ " & vbCrLf &
vbCrLf

Err.Clear
On Error Resume Next

Set WMI = GetObject("WinMgmts:")

If (Err.number 0) Then
MsgBox "Error creating WMI object. Error: " & Err.Number & " - " &
Err.Description
WScript.quit
End If


'-------------- product ------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_ComputerSystemProduct")
S2 = S2 & sBul & " Product Info:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Product Name: " & Ob.Name & vbCrLf
S2 = S2 & "Product Version: " & Ob.Version & vbCrLf
S2 = S2 & "Product Description: " & Ob.Description & vbCrLf
S2 = S2 & "IdentifyingNumber: " & Ob.IdentifyingNumber & vbCrLf
S2 = S2 & "Product UUID: " & Ob.UUID & vbCrLf
Next
S2 = S2 & sLine


'-- box
id --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_SystemEnclosure")
S2 = S2 & sBul & "Machine ID (SystemEnclosure) info:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Part Number: " & Ob.PartNumber & vbCrLf
S2 = S2 & "Serial Number: " & Ob.SerialNumber & vbCrLf
S2 = S2 & "Asset Tag: " & Ob.SMBIOSAssetTag & vbCrLf
Next

S2 = S2 & sLine

'--
motherboard --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_MotherboardDevice")
S2 = S2 & sBul & "Motherboard info:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Caption: " & Ob.Caption & vbCrLf
S2 = S2 & "InstallDate: " & Ob.InstallDate & vbCrLf
S2 = S2 & "DeviceID: " & Ob.DeviceID & vbclrf
Next
S2 = S2 & vbCrLf

'----------- bios -----------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_BIOS")
S2 = S2 & sBul & "BIOS info:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Version: " & Ob.Version & vbCrLf
S2 = S2 & "InstallDate: " & Ob.InstallDate & vbCrLf
S2 = S2 & "SerialNumber: " & Ob.SerialNumber & vbCrLf

Next
S2 = S2 & sLine


'--
CPU --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_Processor")
S2 = S2 & sBul & "CPU:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Name: " & Ob.Name & vbCrLf
S2 = S2 & "Speed: " & Ob.MaxClockSpeed & sLine
Next

'-- RAM and product
info. --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_ComputerSystem")
S2 = S2 & sBul & "Installed RAM: "
For Each Ob in Col
i2 = Ob.TotalPhysicalMemory
If i2 0 Then
i2 = i2 \ 1024 \ 1024
S2 = S2 & CStr(i2) & " MB" & vbCrLf
End If
S2 = S2 & sLine
Next

S2 = S2 & sBul & "PC Info.:" & vbCrLf &vbCrLf

For Each Ob in Col
S2 = S2 & "PC or motherboard model: " & Ob.Model & vbCrLf
S2 = S2 & "System name: " & Ob.Name & vbCrLf
S2 = S2 & "System Manufacturer: " & Ob.Manufacturer & vbCrLf
Next
S2 = S2 & sLine

'---------- onboard devices ----------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_OnBoardDevice")
S2 = S2 & sBul & "Onboard devices:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Name: " & Ob.Name & vbCrLf
S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf
S2 = S2 & "Model: " & Ob.Model & vbCrLf & vbCrLf
Next
S2 = S2 & sLine

'--
graphics --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_VideoController")
S2 = S2 & sBul & "Graphics:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Name: " & Ob.Name & vbCrLf
i2 = Ob.AdapterRAM
If i2 0 Then
i2 = i2 \ 1024 \ 1024
S2 = S2 & "RAM: " & " MB" & vbCrLf
End If
S2 = S2 & "Driver Date: " & Ob.DriverDate & vbCrLf
S2 = S2 & "Driver Version: " & Ob.DriverVersion & vbCrLf
Next
S2 = S2 & sLine

'-- hard
disks --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_DiskDrive")
S2 = S2 & sBul & "Drives:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf
S2 = S2 & "Model: " & Ob.Model & vbCrLf
S2 = S2 & "InterfaceType: " & Ob.InterfaceType & vbCrLf
S2 = S2 & "MediaType: " & Ob.MediaType & vbCrLf
S2 = S2 & "DeviceID: " & Ob.DeviceID & vbCrLf
S2 = S2 & "Number of Win Partitions: " & Ob.Partitions & vbCrLf
s3 = CStr(Ob.Size)
If Len(s3) 9 Then
s3 = Left(s3, (len(s3) - 9))
S2 = S2 & "Size (GB): " & s3
End If
S2 = S2 & vbCrLf & vbCrLf
Next
S2 = S2 & sLine

'-- CD/DVD
drives --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_CDROMDrive")
S2 = S2 & sBul & "CD/DVD drives:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Caption: " & Ob.Caption & vbCrLf
S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf & vbCrLf
Next
S2 = S2 & sLine

'-- network
adapter --------------------------------------------------------------------

Set Col = WMI.ExecQuery("Select * from Win32_NetworkAdapter")
S2 = S2 & sBul & "Network Adapter:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Description: " & Ob.Description & vbCrLf
S2 = S2 & "Name: " & Ob.ProductName & vbCrLf
S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf
S2 = S2 & "MAC Address: " & Ob.MACAddress & vbCrLf & vbCrLf
Next
S2 = S2 & sLine

Set Col = Nothing
Set WMI = Nothing

Dim FSO, TS
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.CreateTextFile(sFil, True)
TS.Write S2
TS.Close
Set TS = Nothing
Set FSO = Nothing
MsgBox "Done."










Ads