Unique Macintosh Identification (Follow-up)

Ken Ray kray at sonsothunder.com
Fri Feb 22 12:08:00 EST 2002


Hey, everyone: Here is what I ended up doing that not only retrieves the MAC Address, but also solves a reported problem of being unable to quit Apple System Profiler:

In order to get the MAC Address from Apple System Profiler, you first need to know that ASP refers to this as the "AppleTalk Address", and that it returns the address in AppleScript's list format (ex: {"00.0a.27.d6.9d.06"}). Secondly, you need to know where ASP *is*, otherwise you'll get the dreaded "Please locate Apple System Profiler:" dialog box. I discovered that if you can let MC locate it (through whatever means you need - directories(), files(), etc.), you need to make sure that the default directory is set to the location of ASP, otherwise you'll get the "Please locate:" box. 

On my Mac (and I believe most modern OS8-9 Macs), ASP is located in the Apple Menu Items folder. So here's the script (assuming MC has found it in the Apple Menu Items folder):

function GetMACAddress
  local tResult
  set the directory to specialFolderPath("apple")
  put "tell application" && quote & "Apple System Profiler" & quote & cr & \
    "get appletalk address" & cr & "end tell" into getMACScript
  put "tell application" && quote & "Apple System Profiler" & quote & cr & \
    "close window" && quote & "Apple System Profiler" & quote & cr & "end tell" into quitASPScript
  
  set the directory to specialFolderPath("apple")
  do getMACScript as AppleScript
  put the result into retVal
  do quitASPScript as AppleScript
  replace "{" with "" in retVal
  replace "}" with "" in retVal
  replace quote with "" in retVal
  return retVal
end GetMACAddress

Note that although you can't send "quit" to ASP, you CAN say "close window 'Apple System Profiler'" and it does the same thing!

Enjoy!

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
  ----- Original Message ----- 
  From: MisterX 
  To: metacard at lists.runrev.com 
  Sent: Thursday, February 21, 2002 12:07 PM
  Subject: RE: Unique Macintosh Identification


  just get the Mac Address of the network card. It's unique for each hardware - model/manuf. regardless!
  You could also generate a time base code coupled with that just to make sure it's never duplicate. I've heard of some duplicate ids in Mac addresses but it's one in a zillion.


    -----Original Message-----
    From: metacard-admin at lists.runrev.com [mailto:metacard-admin at lists.runrev.com]On Behalf Of Ken Ray
    Sent: Thursday, February 21, 2002 18:31
    To: metacard at lists.runrev.com
    Subject: Unique Macintosh Identification


    THis is slightly off-topic, but does anyone know how to uniquely identify a Mac? We're trying to set up a specific install that works on a set number of machines by getting a unique ID for the machine and using it to verify that the machine is "licensed". This doesn't have to specifically be through MetaCard (it could be AppleScript, XCMD, gestalt selector, etc.).

    Thanks!

    Ken Ray
    Sons of Thunder Software
    Email: kray at sonsothunder.com
    Web Site: http://www.sonsothunder.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.runrev.com/pipermail/metacard/attachments/20020222/09e12c9d/attachment.htm


More information about the metacard mailing list