VBS Script – Get Hard Drive Serial Number

The following VBS script can be used to remotely get the serial number from a computers hard drive.

Simply change strComputer to the network name of the remote computer and change the DeviceID to the required hard drive.

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
str = ""
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk Where DeviceID = 'E:'")
For Each objItem In colItems
   str = objItem.VolumeSerialNumber
'   str = str & objItem.Name & " SerialNumber: " & objItem.VolumeSerialNumber & vbCrlf & vbCrlf
Next

tmp = inputBox (VBCrLf,"E Drive Serial Number",str)