Unique Macintosh Identification (Follow-Up)

Ken Ray kray at sonsothunder.com
Fri Feb 22 15:35:01 EST 2002


Awesome find, MisterX! After a little testing and tweaking (the 'findstr' is not "MAC" but "Physical Address", and 'findstr' is not supported on Win 9x), here's a replacement CROSS-PLATFORM function. Note that IPCONFIG.EXE exists only on Windows 98 and higher (including XP), but if you can include IPCONFIG.EXE in your delivery (CD/download/etc.), you can run it on Windows 95 and it will work just fine. (I don't know if Microsoft has an issue with distributing this... you should check it out.

function GetMACAddress
  local retVal
  switch (the platform)
  case "MacOS"
    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
    break
  case "Win32"
    put (there is a file (specialFolderPath("system") & "/IPCONFIG.EXE")) into winExists
    put (there is a file (specialFolderPath("system") & "/SYSTEM32/IPCONFIG.EXE")) into sys32Exists
    if winExists or sys32Exists then
      set the hideConsoleWindows to true
      put shell("ipconfig /all") into temp
      get matchText(temp,"Physical Address. . . . . . . . . : ([A-Z0-9-]*)",retVal)
    else
      return "IPCONFIG not found"
    end if
    break
  end switch
  return retVal
end GetMACAddress

Thanks, everyone!

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/use-livecode/attachments/20020222/ea1aeb90/attachment-0001.html>


More information about the Use-livecode mailing list