Jump to content

Phisical HD serial WMI (Windows XP)


Recommended Posts

(google translate)

Good Morning! I'm trying to find the physical HD Serial using WMI, because I do not know any other way. In Windows Vista / 7/8/10 I managed to get the serial, but on windows XP and lower the serial is different. Can anyone help me with this? I used a script I got from Scriptomatic Tools in the folder "extras / com / Scriptomatic.au3"

 

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$sComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $sComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\")
$colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMedia", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then
   For $objItem In $colItems
      $Output = $Output & "Capacity: " & $objItem.Capacity & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "CleanerMedia: " & $objItem.CleanerMedia & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "HotSwappable: " & $objItem.HotSwappable & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
      $Output = $Output & "MediaDescription: " & $objItem.MediaDescription & @CRLF
      $Output = $Output & "MediaType: " & $objItem.MediaType & @CRLF
      $Output = $Output & "Model: " & $objItem.Model & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "OtherIdentifyingInfo: " & $objItem.OtherIdentifyingInfo & @CRLF
      $Output = $Output & "PartNumber: " & $objItem.PartNumber & @CRLF
      $Output = $Output & "PoweredOn: " & $objItem.PoweredOn & @CRLF
      $Output = $Output & "Removable: " & $objItem.Removable & @CRLF
      $Output = $Output & "Replaceable: " & $objItem.Replaceable & @CRLF
      $Output = $Output & "SerialNumber: " & $objItem.SerialNumber & @CRLF
      $Output = $Output & "SKU: " & $objItem.SKU & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "Tag: " & $objItem.Tag & @CRLF
      $Output = $Output & "Version: " & $objItem.Version & @CRLF
      $Output = $Output & "WriteProtectOn: " & $objItem.WriteProtectOn & @CRLF
      If MsgBox(1,"WMI Output",$Output) = 2 Then ExitLoop
      $Output=""
   Next
Else
   MsgBox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PhysicalMedia" )
EndIf


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

 

 

SerialNumber: 38303638314a5946313833353637 0 0 0 0 0 0

omNBEte.png

 

In other program is normal... \/

3h20iFX.png

 

 

Link to comment
Share on other sites

The SerialNumber propertie does not exists in Win32_DiskDrive on Windows XP.

Try this one (thrid example in #8). @KaFu made a good job with WMISerialNumberConversion

 

Edited by jguinch
Link to comment
Share on other sites

Win32_PhysicalMedia seems to be the only property that will provide a real serial number.

Not very organized, since Win32_DiskDrive should have that data in it, plus a few others.

In any case, here's the proper way for WMIC - though, you will probably get the same results as post #1...

WMIC /NAMESPACE:\\root\CIMV2 PATH Win32_PhysicalMedia GET SerialNumber,Tag

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...