1

I am looking for a batch command to retrieve an USB key manufacturer serial number. I need a command that works in both Windows XP and Windows Seven.

This is for a hardware follow-up. I have a script that sends emails when a problem occurs and it needs to include a way to identify the removable disk.

At first I used vol e: but the number changes when the disk is formatted.

On several sites I saw wmic diskdrive get serialnumber but it doesn't seem to work (at least on W7). The command returns Invalid XML.

This is not surprising. I ran wmic diskdrive get /? and the available options are:

Property                               Type                    Ope
========                                ====                    ===
Availability                            N/A                     N/A
BytesPerSector                          N/A                     N/A
Capabilities                            N/A                     N/A
CapabilityDescriptions                  N/A                     N/A
CompressionMethod                       N/A                     N/A
ConfigManagerErrorCode                  N/A                     N/A
ConfigManagerUserConfig                 N/A                     N/A
DefaultBlockSize                        N/A                     N/A
Description                             N/A                     N/A
DeviceID                                N/A                     N/A
ErrorCleared                            N/A                     N/A
ErrorDescription                        N/A                     N/A
ErrorMethodology                        N/A                     N/A
Index                                   N/A                     N/A
InstallDate                             N/A                     N/A
InterfaceType                           N/A                     N/A
LastErrorCode                           N/A                     N/A
Manufacturer                            N/A                     N/A
MaxBlockSize                            N/A                     N/A
MaxMediaSize                            N/A                     N/A
MediaLoaded                             N/A                     N/A
MediaType                               N/A                     N/A
MinBlockSize                            N/A                     N/A
Model                                   N/A                     N/A
Name                                    N/A                     N/A
NeedsCleaning                           N/A                     N/A
NumberOfMediaSupported                  N/A                     N/A
PNPDeviceID                             N/A                     N/A
Partitions                              N/A                     N/A
PowerManagementCapabilities             N/A                     N/A
PowerManagementSupported                N/A                     N/A
SCSIBus                                 N/A                     N/A
SCSILogicalUnit                         N/A                     N/A
SCSIPort                                N/A                     N/A
SCSITargetId                            N/A                     N/A
SectorsPerTrack                         N/A                     N/A
Signature                               N/A                     N/A
Size                                    N/A                     N/A
Status                                  N/A                     N/A
StatusInfo                              N/A                     N/A
SystemName                              N/A                     N/A
TotalCylinders                          N/A                     N/A
TotalHeads                              N/A                     N/A
TotalSectors                            N/A                     N/A
TotalTracks                             N/A                     N/A
TracksPerCylinder                       N/A                     N/A

No SerialNumber...

Do you have a better idea?

Thanks

4
  • What do you mean by "doesn't seem to work"?
    – gronostaj
    May 27, 2013 at 12:23
  • I edited my question.
    – Maxbester
    May 27, 2013 at 12:28
  • wmic diskdrive get serialnumber does seem to return multiple 40-digit numbers (one per drive) on Win7 x64.
    – Karan
    May 27, 2013 at 23:35
  • Gosh... Why doesn't it work for me?!? What is the cause of the Invalid XML error?
    – Maxbester
    May 29, 2013 at 7:55

1 Answer 1

3

I've finally found the solution on Stackoverflow.

The SerialNumber property doesn't exist.

I now use:

wmic diskdrive get PNPDeviceID

But a fix exists from Microsoft here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .