1

For get the serial number of all hard drives in my computer, I use:

wmic diskdrive get serialnumber

But, I want to get the serial number of the hard drive where I am working.

I explain: I have 2 hard drives, one of them has 2 partitions C and D. The other has one partition E. With the command line, if I am working in C partition, when I type the wmic command, I want to get only the serial number of the hard drive which has this partition, not the serial of the hard drive with the E partition.

I want to make a license code for my software. you can install the software in any partition. i want the serial number of the hard drive that contains these partition specifycally. the volume serial number of the partition changes when you format, reinstall, etc, but the serial number of the hard drive not. i know there are softwares to change the serial number, but my possible clients are not so smarts.

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

2 Answers2

3

Thanks to everyone for your replies. I found an answer that is what I need, here I share it with you. The command is in powershell:

Get-Disk (Get-Partition -DriveLetter 'C').DiskNumber

The output is something like this:

Number Friendly Name Serial Number  HealthStatus OperationalStatus       Total Size Partition Style
------ ------------- -------------------------------------------------- 
0      ST3802110AS    5LR2DQ65       Healthy          Online               74.53 GB    MBR
Daril Alemán
  • 118
  • 1
  • 2
  • 13
0

Here is a Powershell script I made that hopefully does what you want.

  1. Open Powershell
  2. Copy and paste this:
$volumes = get-wmiobject Win32_Volume
foreach ($vol in $volumes) 
  {
    if($vol.Caption -eq 'c:\')
      {
        $vol | fl Caption,Name,DeviceID,SerialNumber 
      }
  }
pause

This should get you what you want in relation to the C:\ drive. If you want a different drive letter, simply change it in the script above on the 4th line where it says c:\

The output will look like:

Caption      : C:\
Name         : C:\
DeviceID     : \\?\Volume{770f1368-bacc-4401-98db-a6c43bc4ef11}\
SerialNumber : 3469401274

Note: If you want all the available drive info and not just those 4 things, you can remove | fl Caption,Name,DeviceID,SerialNumber from the above and just leave $vol on that line instead.

Narzard
  • 3,840