We've had issues with the computers here after a migration with some important fonts being disabled. I made this script up to quickly fix the issue, I'm no scripting expert, I just wanted a quick way to do this for 200+ computers. I want it to run the script when the user logs into the computers. I get 2 different errors. I understand both but don't know how to fix them.
First error ----
/Library/Application Support/JAMF/tmp/fontfix.applescript:65:80: execution error: An error of type -10810 has occurred. (-10810)
Second error ----
Script result: 2016-09-27 11:02:52.314 osascript[2788:334116] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2016-09-27 11:02:52.315 osascript[2788:334116] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2016-09-27 11:02:52.315 osascript[2788:334116] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2016-09-27 11:02:52.315 osascript[2788:334116] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2016-09-27 11:02:52.394 osascript[2788:334116] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2016-09-27 11:02:52.395 osascript[2788:334116] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
The script I'm using is below. I'm guessing these errors have to deal with it trying to open an app not being the current user that is logged in. What can I do to fix this issue? If I run the policy from terminal on the computers it works, but when it is run by its trigger it fails with those errors.
tell application "Font Book" to set {fontNames, fontEnableds} to {name, enabled} of font families
set activeFontsList to {}
set inactiveFontsList to {}
repeat with i from 1 to (count fontEnableds)
if (item i of fontEnableds) then
else
set end of inactiveFontsList to item i of fontNames
end if
end repeat
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to linefeed
set inactiveFontsList to inactiveFontsList as text
set AppleScript's text item delimiters to astid
set desktopPath to ("Macintosh HD:Users:Shared:" as text)
writeFile of inactiveFontsList to (desktopPath & "InactiveFonts.txt")
on writeFile of txt to destPath
set accessRef to (open for access file destPath with write permission)
try
set eof accessRef to 0
write txt to accessRef
end try
close access accessRef
end writeFile
set lf to (ASCII character 10)
tell application "Font Book"
set savedListSpec to (desktopPath & "InactiveFonts.txt")
set savedList to open for access savedListSpec
repeat
try
set typefaceToReactivate to (read savedList before lf)
on error
exit repeat
end try
if (offset of "*" in typefaceToReactivate) is 0 then
try
set enabled of typeface typefaceToReactivate to true
end try
end if
end repeat
end tell
tell application "Font Book"
quit
end tell