Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get HARDWARE serial-number of hard-disk drives with WMI (or any other reliable API)

Posted on 2014-07-28
21
Medium Priority
?
12,882 Views
Last Modified: 2017-07-23
I am trying to get the HARDWARE Serial Numbers of hard-disk drives (which includes SSDs) with WMI (Windows Management Instrumentation):

Class: Win32_DiskDrive
Namespace: root\CIMV2

Now, a customer's computer contains 4 Western Digital hard-disk drives:

WDC WD2002FYPS-02W3B0 ATA Device
WDC WD2003FYYS-02W0B0 ATA Device
WDC WD3000GLFS-01F8U0 ATA Device
WDC WD30EZRX-00MMMB0 ATA Device

And these are the serial numbers of these 4 hard-disk drives I got with the above WMI query:

2020202057202d44435756413559323535303937
2020202057202d444d5759413030303834323931
2020202057202d445857354c3830353035313836
2020202057202d4443575741305a343930343730

Please note that these serial-numbers are very similar, so I cannot believe these are the real serial-numbers of these hard-disk drives.
So I used a professional hardware information program (HWiNFO) to compare these serial-numbers with those detected from HWiNFO, and they were totally different.

So I wonder whether it is possible to query the REAL hardware serial-numbers of hard-disk drives by using WMI?
0
Comment
Question by:PeterDelphin
  • 9
  • 8
  • 3
  • +1
21 Comments
 
LVL 13

Expert Comment

by:duncanb7
ID: 40225265
What is serial number you get from  (HWiNFO)  ? Could you send it us for comparsion ?


Duncan
0
 

Author Comment

by:PeterDelphin
ID: 40225281
These are the serial-numbers I get from HWiNFO:

Drive Serial Number:  WD-WCAVY5520579
Drive Serial Number:  WD-WMAY00802419
Drive Serial Number:  WD-WXL508051568
Drive Serial Number:  WD-WCAWZ0944007

Meanwhile I've also checked with another hardware information tool: These from HWiNFO are correct.
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40225326
Could you try this on command line

wmic diskdrive list brief  /format:list

to see any different ?

Duncan
0
 

Author Comment

by:PeterDelphin
ID: 40225356
Here is the result of the command:

Caption=WDC WD2002FYPS-02W3B0 ATA Device
DeviceID=\\.\PHYSICALDRIVE1
Model=WDC WD2002FYPS-02W3B0 ATA Device
Partitions=3
Size=2000396321280

Caption=WDC WD2003FYYS-02W0B0 ATA Device
DeviceID=\\.\PHYSICALDRIVE2
Model=WDC WD2003FYYS-02W0B0 ATA Device
Partitions=1
Size=2000396321280

Caption=WDC WD3000GLFS-01F8U0 ATA Device
DeviceID=\\.\PHYSICALDRIVE3
Model=WDC WD3000GLFS-01F8U0 ATA Device
Partitions=2
Size=300066439680

Caption=WDC WD30EZRX-00MMMB0 ATA Device
DeviceID=\\.\PHYSICALDRIVE4
Model=WDC WD30EZRX-00MMMB0 ATA Device
Partitions=0
Size=3000590369280
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40225384
the  serialnumber in your post seems size number for two disks

please try it one more

wmic diskdrive get serialnumber

Duncan
0
 

Author Comment

by:PeterDelphin
ID: 40225428
Here is the result:

2020202057202d44435756413559323535303937
2020202057202d444d5759413030303834323931
2020202057202d445857354c3830353035313836
2020202057202d4443575741305a343930343730
0
 

Author Comment

by:PeterDelphin
ID: 40225439
BTW, have you tried it yourself on your own computer and compared to the serial number in HWiNFO?
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40225445
I also check your tools (hw32) and other internet tools on my driver  all are same serial and is different from
wmic but it is strange the number is closer to similar  and just swap between integer in the number

for example,
HDD_ID reports    WD-WXR1EB0TWS04
HW32 reports       WD-WXR1EB0TWS04
WMIC reports       W -DXW1RBET0SW40

You may be right. But Microsoft is huge company. How do you think to trust which one  ?

Duncan
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40225450
And model number all correct on WMIC, HW32, HDD_ID
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40225485
Could we mount off the disk drive and read the serial number on back side of the disk provided from manufacturer ? If possible, that will know which tools is more accurate. My computer is laptop that is hard to mount or take it off.


Duncan
0
 

Author Comment

by:PeterDelphin
ID: 40225580
OK, will try it tomorrow morning.
0
 

Author Comment

by:PeterDelphin
ID: 40226026
It's like I suspected: The serial numbers printed on the hardware are the same as I got from HWiNFO.

So the numbers from wmic are clearly wrong.
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40226032
Great work, wmic is wrong on my laptiop and yours, and you also proved it from hardware.  Probably is wmic 's issue but the testing sample is small.  I will create new thread for  asking who will be interested to test wmic on window for serial number  to collect more statistic information that not just prove hw32 correct but also WMIC incorrect


Duncan
0
 

Author Comment

by:PeterDelphin
ID: 40226097
So is there any other reliable API (as asked in my question title) to get the serial-number of hard-disk drives?
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40226102
I don't have such API,
To answer your question post, WMIC can not get the hard disk serial number.

Duncan
0
 
LVL 17

Expert Comment

by:Gerald Connolly
ID: 40226349
Why do you need the serial numbers?
0
 

Author Comment

by:PeterDelphin
ID: 40227028
I am a software developer. I need it to get a unique hardware ID for licensing purposes, and the hard-disk drive serial number is part of that.
0
 
LVL 17

Expert Comment

by:Gerald Connolly
ID: 40227670
Doesnt sound like a good plan. Disks change a lot, and some RAID controllers (probably all) give made up serial numbers, probably the same one on all systems.

I would of thought something like the MAC address would be a better bet?
0
 

Author Comment

by:PeterDelphin
ID: 40227716
Gerald Connolly wrote: "Doesnt sound like a good plan. Disks change a lot, and some RAID controllers (probably all) give made up serial numbers, probably the same one on all systems.

I would of thought something like the MAC address would be a better bet?
"

Oh come on, let this be my problem. The main topic here (as stated in the question title) is how to get the serial number, either with WMI or other API.
0
 
LVL 14

Accepted Solution

by:
Rob Miners earned 1500 total points
ID: 40227957
If you only need the Serial Number and Hard drive identification try this I don't know if it will work on raid though as I can't test it.

wmic path win32_physicalmedia get SerialNumber, Tag

wmic path win32_physicalmedia get SerialNumber, Tag >%temp%\SerialNumber.txt & start notepad %temp%\SerialNumber.txt

I found it easier to combine two commands if you need the Model number.

wmic path win32_physicalmedia get SerialNumber, Tag & wmic diskdrive get model

wmic path win32_physicalmedia get SerialNumber, Tag >%temp%\SerialNumber.txt & wmic diskdrive get model >>%temp%\SerialNumber.txt & start notepad %temp%\SerialNumber.txt

It produces similar output to your first post.

Note:
This command line works straight up in 8.1

C:\WINDOWS\system32>wmic diskdrive get name, serialnumber, model
Model                          Name                SerialNumber
ST2000DM001-9YN164 ATA Device  \\.\PHYSICALDRIVE0  W1F1D6Y0
ST31000528AS ATA Device        \\.\PHYSICALDRIVE1  9VP8QB51

The same command line in Windows 7 produces the serial number in string format:


C:\Windows\system32>wmic diskdrive get name, serialnumber, model
Model                          Name                SerialNumber
ST2000DM001-9YN164 ATA Device  \\.\PHYSICALDRIVE0  202020202020202020202020315a304531563331
0
 
LVL 17

Expert Comment

by:Gerald Connolly
ID: 40228587
@peter, i was just trying to point out that in simple systems you may get the real Disk Serial number, but if the system is using RAID the OS may not even have access to the real Disks, it will only see the LUN presented by the RAID controller.
The serial number of this LUN will have been generated by the controller. NB Most controllers can do RAIDsets of 15 or more disks so they generate one. Is it going to be unique? Unlikely.
0
Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last few years, video game fans have found a new favorite pastime: Watching and creating live-streaming gaming sessions. Twitch.TV has emerged as an industry leader in making game streaming painless for those looking to share their Starcraf…
School is back in session! The beginning of the school year is a fresh slate. One way for students to get started on the right foot is to get organized.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question