Sign in to follow this  
Followers 0
taz5176

DriveGetSerial report different hdd serial no.

15 posts in this topic

hi all

$var = DriveGetSerial( "c:\" )

MsgBox(4096, "Serial Number: ", $var)

My hdd serial is 4MQ08LX3

the above script return 2004997699

Is DriveGetSerial returning the correct value?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

My hdd serial is 4MQ08LX3

go to command prompt at C:\ and type "vol" Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hi all

$var = DriveGetSerial( "c:\" )

MsgBox(4096, "Serial Number: ", $var)

My hdd serial is 4MQ08LX3

the above script return 2004997699

Is DriveGetSerial returning the correct value?

as d4rk points out, it returns the serial number of a volume, not the serial of a physical drive.

Edit: I thought that maybe using WMI Win32_DiskDrive would get it but that doesn't do it either. It will return the model but not the serial.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Under Vista WMI will return the HDD SN#.


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Dup post... bah

Edited by Kerros

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

Under Vista WMI will return the HDD SN#.

Must be the difference in the WMI version. I just updated my WMI a couple of weeks ago and It still doesnt return it. That's on XP

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This should show the serial numbers for all drives:

; Generated by AutoIt Scriptomatic

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

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.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

EDIT: Wrong WMI location

Edited by weaponx

Share this post


Link to post
Share on other sites

@weaponx

That script will not return the actual Disk Drive SN#. That may return the Volume information, but to get to the physical drive we would need to use Win32_DiskDrive.

This is what was created by scriptomatic under Vista and XP on the same machine.

Vista.

; Generated by AutoIt Scriptomatic
 
 $wbemFlagReturnImmediately = 0x10
 $wbemFlagForwardOnly = 0x20
 $colItems = ""
 $strComputer = "localhost"
 
 $Output=""
 $Output = $Output & "Computer: " & $strComputer  & @CRLF
 $Output = $Output & "==========================================" & @CRLF
 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
 $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
                                           $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
 
 If IsObj($colItems) then
    For $objItem In $colItems
       $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
       $Output = $Output & "BytesPerSector: " & $objItem.BytesPerSector & @CRLF
       $strCapabilities = $objItem.Capabilities(0)
       $Output = $Output & "Capabilities: " & $strCapabilities & @CRLF
       $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0)
       $Output = $Output & "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF
       $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
       $Output = $Output & "CompressionMethod: " & $objItem.CompressionMethod & @CRLF
       $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
       $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
       $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
       $Output = $Output & "DefaultBlockSize: " & $objItem.DefaultBlockSize & @CRLF
       $Output = $Output & "Description: " & $objItem.Description & @CRLF
       $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
       $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
       $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
       $Output = $Output & "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF
       $Output = $Output & "FirmwareRevision: " & $objItem.FirmwareRevision & @CRLF
       $Output = $Output & "Index: " & $objItem.Index & @CRLF
       $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
       $Output = $Output & "InterfaceType: " & $objItem.InterfaceType & @CRLF
       $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
       $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
       $Output = $Output & "MaxBlockSize: " & $objItem.MaxBlockSize & @CRLF
       $Output = $Output & "MaxMediaSize: " & $objItem.MaxMediaSize & @CRLF
       $Output = $Output & "MediaLoaded: " & $objItem.MediaLoaded & @CRLF
       $Output = $Output & "MediaType: " & $objItem.MediaType & @CRLF
       $Output = $Output & "MinBlockSize: " & $objItem.MinBlockSize & @CRLF
       $Output = $Output & "Model: " & $objItem.Model & @CRLF
       $Output = $Output & "Name: " & $objItem.Name & @CRLF
       $Output = $Output & "NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF
       $Output = $Output & "NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF
       $Output = $Output & "Partitions: " & $objItem.Partitions & @CRLF
       $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
       $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
       $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
       $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
       $Output = $Output & "SCSIBus: " & $objItem.SCSIBus & @CRLF
       $Output = $Output & "SCSILogicalUnit: " & $objItem.SCSILogicalUnit & @CRLF
       $Output = $Output & "SCSIPort: " & $objItem.SCSIPort & @CRLF
       $Output = $Output & "SCSITargetId: " & $objItem.SCSITargetId & @CRLF
       $Output = $Output & "SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF
       $Output = $Output & "SerialNumber: " & $objItem.SerialNumber & @CRLF
       $Output = $Output & "Signature: " & $objItem.Signature & @CRLF
       $Output = $Output & "Size: " & $objItem.Size & @CRLF
       $Output = $Output & "Status: " & $objItem.Status & @CRLF
       $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
       $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
       $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
       $Output = $Output & "TotalCylinders: " & $objItem.TotalCylinders & @CRLF
       $Output = $Output & "TotalHeads: " & $objItem.TotalHeads & @CRLF
       $Output = $Output & "TotalSectors: " & $objItem.TotalSectors & @CRLF
       $Output = $Output & "TotalTracks: " & $objItem.TotalTracks & @CRLF
       $Output = $Output & "TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF
       if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
       $Output=""
    Next
 Else
    Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_DiskDrive" )
 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

I am also attaching screenshots of the output information for those that can not try it themselves.

Vista

Posted Image

XP Service Pack 2

Posted Image


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

The code I posted shows the same serial number as reported by Everest Ultimate Edition (WD-WMANS2159481).

Edited by weaponx

Share this post


Link to post
Share on other sites

The code I posted shows the same serial number as reported by Everest Ultimate Edition (WD-WMANS2159481).

Win32_LogicalDisk only gives the Volume Serial.

Share this post


Link to post
Share on other sites

Which value is returning the SN#?

When I run Win32_LogicalDisk from Scriptomatic "VolumeSerialNumber: " is blank except when viewing my network drives, which would not return a drive SN# as they are part of a RAID array.


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

I posted the wrong script. It was supposed to be from Win32_PhysicalMedia.

Share this post


Link to post
Share on other sites

Weird, I can't get any results from Win32_PhysicalMedia except Tag. Also, DriveGetSerial() returns a number that is not my Vol Serial, and not physically printed on my HD.

Share this post


Link to post
Share on other sites

I only get tag from Win32_PhysicalMedia as well. DriveGetSerial() is returning VolumeSerialNumber I believe.


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

I posted the wrong script. It was supposed to be from Win32_PhysicalMedia.

Right you are. Physical Media returns it for me.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
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
Sign in to follow this  
Followers 0