1

I run below command in cmd in Windows:

wmic diskdrive get serialnumber

which gives me the following result:

SerialNumber
W2B0MMLM
S2SMJ9DD906854

What if I only want primary harddisk's serial number only?

Vishal
  • 161

1 Answers1

1

You could try this:

wmic logicaldisk where (DeviceID="C:") assoc /assocclass:Win32_LogicalDiskToPartition

With this command you get the partition id ("Disk #0, Partition #0"). (If you have the system installed on C drive. You can change the letter anytime)

wmic partition where (DeviceID="Disk #0, Partition #0") assoc /assocclass:Win32_DiskDriveToDiskPartition

With this command you get the physical drive id ("\\.\PHYSICALDRIVE0")

wmic path win32_diskdrive where deviceid='\\\\.\\PHYSICALDRIVE0' get serialnumber

With this you get the serial number of the primary hard disk.

Daril Alemán
  • 118
  • 1
  • 2
  • 13