VBS Script – Get USB Drive Serial Number

Many USB drives (particularly USB ‘thumb drives’) do not have the unique serial number printed on the outside.

Sometimes there is a need to use the unique hardware serial number for asset record management or auditing.

The following script can be used to get the serial number for a USB Drive (or hard drive) connected to the computer.


When you run the script it will ask for the drive letter (e.g. E)


After entering the drive letter and clicking ‘OK’ it will return the serial number for the device.

It will also return the drive type, file system, free space (in MB) and total size (in MB).

The serial number is presented in a text box which allows you to copy and paste it into another window.


VBS Script:

strComputer = "."
usbdrive = InputBox ("Enter the USB Drive Letter")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk Where DeviceID ='" & usbdrive & ":'")
For Each objItem In colItems
SerialNumber = objItem.VolumeSerialNumber
DriveType = objItem.Description
FileSystem = objItem.FileSystem
FreeSpace = (objItem.FreeSpace / 1048576)
TotalSize = (objItem.Size / 1048576)


tmp = inputBox ("Drive Type: " & DriveType & vbNewLine & "File System: " & FileSystem & vbNewLine & "Free Space: " & FreeSpace & " MB" & vbNewLine & "Total Size: " & TotalSize & " MB" , "USB Drive Serial Number",SerialNumber)

Article Downloads

TIP: You may need to right-click and select 'save link as'.