I think this should be easy, but I can’t find the answer.
How can an Applescript test whether it has been launched by a user with a standard account or one with an administrative account? I want the script to copy some files into one folder if the user has a standard account, but into a different folder if the user has an administrative account.
this handler checks whether the current user has admin status
checkAdminAccount()
on checkAdminAccount()
set {short user name:shortName} to (system info)
set admins to do shell script "/usr/bin/dscl . -read /Groups/admin | /usr/bin/grep GroupMembership"
set {TID, text item delimiters} to {text item delimiters, space}
set admins to text items 2 thru -1 of admins
set text item delimiters to TID
return {shortName} is in admins
end checkAdminAccount
checkAdminAccount()
on checkAdminAccount()
local admins, shortName
set shortName to short user name of (system info)
set admins to rest of words of (do shell script "/usr/bin/dscl . -read /Groups/admin GroupMembership")
return shortName is in admins
end checkAdminAccount