Getting the Serial Number of the User's computer

Ken Ray kray at sonsothunder.com
Tue Dec 9 17:06:02 EST 2008


> How can I retrieve the computer serial number in OS X, Vista and
> Linux from Rev?

Here's what I have, Paul... for OS X it can take a while (a few seconds) to
get the number on OS X (since it has to go through a series of different
"system_profiler" data types), but it works (watch for wraps):

function stsGetSerialNumber pWinDriveLetter
   local tID
   switch (the platform)
      case "MacOS"
         put shell("system_profiler SPHardwareDataType") into tData
         put matchText(tData,"(?s)Serial Number:\W*(.*?)\n",tID) into
tIsMatch
      break
      case "Win32"
         if pWinDriveLetter = "" then put "C:" into tDriveLetter
         else put pWinDriveLetter into tDriveLetter
         if length(tDriveLetter) = 1 then put ":" after tDriveLetter
         set the hideConsoleWindows to true
         if the shellCommand <> "command.com" then
            put shell(tDriveLetter && "& dir") into tData
         else
            put "c:\temp.bat" into tBatPath
            put tDriveLetter & cr & "dir" into url ("file:" & tBatPath)
            put shell("start" && tBatPath) into tData
            delete file tBatPath
         end if
         put matchText(tData,"(?s)Serial Number is\W*(.*?)\n",tID) into
tIsMatch
      break
   end switch
   if tIsMatch then
      return tID
   else
      return "STSError: Can't locate serial number."
   end if
end stsGetSerialNumber


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list