Win32_diskdrive Serial Number Average ratng: 6,1/10 3007 votes

5 thoughts on “ Getting a list of logical and physical drives from the command line ” J2u 30 January 2014 at 4:47 pm. Hello, How can i extract the specific fields using wmic diskdrive or wmic logicaldisk. For example i want to output the size and number or partitions to a text file as follows. You can get it by using a command at command prompt: C: > vol c: if C: is the drive you want to retrieve the Volume Serial Number for. This command gets an instance of the Win32_DiskDrive WMI class and outputs the model of each disk drive in the computer and its corresponding serial number from that instance.

  1. Serial Number Lookup
  2. Win32_diskdrive Serial Number C++
  3. Win32_diskdrive Serial Number Windows Xp
Active5 years, 1 month ago

I want to read the name and the serialnumber of my Hard-Drives.

I stumbled upon wmic but i'm having troubles. I guess these two commands should do the trick, but I only get the message:

or

I tried the following aswell:

Any ideas on what I'am doing wrong?

Win32_diskdrive Serial Number

Solution:

Thanks JPBlanc,via the /? command i've found out that SerialNumber doesn't even exist. I now use

which gives the correct result.

Paul Hiemstra
49.9k10 gold badges117 silver badges136 bronze badges
user1210404user1210404

3 Answers

You are just making a mistake usin WMIC command line, WMIC DISKDRIVE GET SerialNumber /Format /? gives you keywords:

Serial Number Lookup

you can try :

You can replace RAWXML by one of the others formats.

JPBlancJPBlanc
54.5k10 gold badges100 silver badges134 bronze badges

this issue occurs because the XML parser treats the control characters that are included in the serial number of some drives as invalid.

juejue

I was getting this error on Windows 7 x86 Pro (where querying the serial number should be possible) when an external drive was connected.

This is how I fixed it:

  1. Get the ID of each drive: wmic diskdrive get deviceid /format:list

  2. Parse the output and get the first ID. In my case this was.PHYSICALDRIVE0

  3. Escape the backslashes so that the ID is .PHYSICALDRIVE0

  4. Get the serial number of the drive using its escaped ID:

    wmic diskdrive where deviceid='.PHYSICALDRIVE0' getserialnumber /format:list

  5. Repeat steps 2 - 4 until you have the serial numbers of all drives

Edit: The above doesn't work on my copy of Windows XP x86 Pro.

This does:

Matthias BraunMatthias Braun
15.7k12 gold badges87 silver badges123 bronze badges
Win32_diskdrive

Not the answer you're looking for? Browse other questions tagged wmiserial-numberwmic or ask your own question.

Active5 years, 3 months ago

How to get Hard Disk number from drive letter using VBScript?

Thank you in advance.

Leonid F.Leonid F.
1973 gold badges3 silver badges20 bronze badges

3 Answers

Remou is right about WMI, just have to make it a little bit more messy. Wouldn't be at all surprised if there's an easier/better way of doing this, but this script should at least give you a good starting point for doing what you need.

This will enumerate all drive letters and give you the results as for example: C: - Disk #2, Partion #0

Hans Olsson

Win32_diskdrive Serial Number C++

Hans Olsson
45.5k12 gold badges82 silver badges106 bronze badges
FionnualaFionnuala
85.7k7 gold badges95 silver badges133 bronze badges

This is not the exact answer but in case some need it in C# use this function that I just created

Ricardo PoloRicardo Polo

Win32_diskdrive Serial Number Windows Xp

Win32_diskdrive Serial Number
5,52411 gold badges40 silver badges75 bronze badges

Not the answer you're looking for? Browse other questions tagged vbscript or ask your own question.