Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

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

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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