Hard drive serial number

Ken Ray kray at sonsothunder.com
Mon Jan 17 13:35:46 EST 2005

On 1/17/05 11:59 AM, "Ken Ray" <kray at sonsothunder.com> wrote:

> I'll add in getting the HD Serials to my next post.

Here you go (watch for line wraps):

on mouseUp
  get stsGetSerialNumber("machine")  -- get machine serial (OS X)
  get stsGetSerialNumber(line 1 of the drives)  --get first HD serial (OS X)
  get stsGetSerialNumber("c:") -- get main HD serial (Windows)
end mouseUp

function stsGetSerialNumber pParam
  local tID
  switch (the platform)
  case "MacOS"
    if isOSX() then
      if (pParam = "") or (pParam="machine") then
        put shell("system_profiler SPHardwareDataType") into tData
        put matchText(tData,"(?s)Serial Number:\W*(.*?)\n",tID) into
        put pParam into tDriveName
        put shell("system_profiler SPIDEDataType") into tData
        put lineOffset(tDriveName & ":",tData) into tLine
        put false into tIsMatch
        repeat with x = tLine down to 1
          put line x of tData into tDataLine
          if tDataLine contains "Serial Number:" then
            put matchText(tDataLine,"(?s)Serial Number:\W*(.*?)$",tID) into
            exit repeat
          end if
        end repeat
      end if
      -- No OS 9 version yet
    end if
  case "Win32"
    if pParam = "" then put "C:" into tDriveLetter
    else put pParam 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
      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
  end switch
  if tIsMatch then
    return tID
    return "Error: Can't locate serial number."
  end if
end stsGetSerialNumber

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

More information about the Use-livecode mailing list