osx - applescript (10.9) Can’t make alias into type specifier -


the below applescript registers appuninstaller.scpt folder action trash folder. registering folder action script works fine in mac osx 10.7 , 10.8.

in 10.9, error "attach error system events got error: can’t make alias "macintosh hd:users:[username]:.trash:" type specifier."

the error occurs while executing statement

 attach action _trashfolder using _uninstallerscriptpath 

the complete script below.

on run     tell utils          init()         registerfolderaction()      end tell end run   script utils       property _uninstallerscript : "appuninstaller.scpt"       property _resrelativepath : ":applications:testdemo.app:contents:resources:"       property _folderactionscriptrelativepath : "scripts:folder action scripts"        global _respath       global _trashfolder       global _uninstallerscriptpath        on init()                   -- setup paths                 set _trashfolder path trash folder                  set _uninstallerscriptpath getuninstallerscript()                    -- add boot disk name app relative path                 tell application "finder"                           set startupdisk (name of startup disk)                           set _respath startupdisk & _resrelativepath                 end tell                  set scriptfolderpath getscriptpath()               -- copy folder action script file appbundle scripts folder              copyscript()        end init        on registerfolderaction()                 try                      tell application "system events"                           set folder actions enabled true                           log _uninstallerscriptpath                            -- problem below statement.                           attach action _trashfolder using _uninstallerscriptpath                            end tell                 on error msg                           display dialog "attach error " & msg                 end try        end registerfolderaction        on getscriptpath()                 return ((path library folder user domain) string) & _folderactionscriptrelativepath       end getscriptpath        on getuninstallerscript()                 return getscriptpath() & ":" & _uninstallerscript       end getuninstallerscript        -- copying script inside app bundle scripts folder.       on copyscript()                 tell application "finder"                           set srcfile _respath & _uninstallerscript                           set dstfile getscriptpath()                            log "src file " & srcfile & " dstfolder " & dstfile                           duplicate file srcfile dstfile replacing                 end tell       end copyscript  end script 

looking @ error (and after testing myself) seems in pre-mavericks systems first argument of attach action to command coerced file/folder object specifier when argument alias. in mavericks coercion somehow doesn't happen , error occur because given argument not object/type specifier alias class. first argument of attach action to needs object/type specifier can solve problem forcing coercion when command called.

attach action folder (_trashfolder text) using _uninstallerscriptpath  

you can same argument using


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -