Retrieving the Volume Serial Number
Windows Only (Windows Only)

The following function allows you to get the unique serial number of any drive you point it to. This can be used for security or identification purposes.

Note that if you point it to the "A" drive, you will get either "0000-0000" or will get a "Disk not found" result (depending on your version of Windows), and if you point it to a removeable drive (like a CD or Zip drive) and there is no media in the drive, you will get a "Disk not found" response.

on mouseUp
  answer GetVolumeSN("C")
end mouseUp

function GetVolumeSN pDiskLetter
  local volumeSerialNumber
  -- Supports both "C", "C:" and "C:\" styles
  put char 1 of pDiskLetter & ":" into pDisk
  set the hideConsoleWindows to true
  put shell("dir " & pDisk) into tDirData
  return (word -1 of line 2 of tDirData)
end GetVolumeSN

Updated 4/18/14 by Ken Ray Posted 7/31/02 by Ken Ray