To make double-clicking a file to open it in a certain application, I have since several years used:
set default application of (anItem as alias) to path to application id "com.adobe.Acrobat.Pro"
It has worked very well, but since some of the later OS “upgrades” it no longer works. I know it worked in Mountain Lion, and I think in early Mavericks but I’m unsure. No errors, but it simply won’t set a new value for the default application.
The dictionary for System Events has not changed.
It is still possible to query: default application of (anItem as alias), which correctly tells me the current value of the default application for this item. But it will not set a new value.
Calling and changing launchservices will affect all files with that extension (in my case a pdf file). I want to set only designated files to open in Acrobat rather then Preview, and that has always been possible before. (It corresponds to Get Info of a file in Finder, then change “Open With”. System Events used to be able to do that, and its dictionary still says it should be able to do that.)
As for restart, I already tried that, but it did not help.
If the small script I showed really works for somebody else (running Mavericks), that would be strange, and it would indicate that there is something wrong with my particular computer, but I doubt.
set adobeAcrobat to path to application id "com.adobe.Acrobat.Pro" as text
tell application "System Events"
set default application of (anItem as alias) to disk item adobeAcrobat
end tell
That one works for me also!
Obviously, somewhere along Apple’s OS upgrades/updates, the property default application no longer accepts alias but it does accept disk item.
The dictionary says for the System Events’ alias that its property default application is “disk item or any”. It has always worked with alias as “any”, but now, only disk item seems to work.
So, my original statement can thus be modified into the following working statement:
set default application of (anItem as alias) to disk item (path to application id "com.adobe.Acrobat.Pro" as text)