"set default application of..." no longer works! Any workaround?

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.

So, anybody know of a solution?

Hi heb,

I think you can change the plist for launch services or you might just need to restart the machine. These look like the default apps:

do shell script "defaults read 'com.apple.launchservices'"

You might want to do some research into this.

gl,
kel

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.

Hi,

this works for me in Mavericks


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

Thanks a zillion Stefan!

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)

Yeah, disk item is a new one on me, but I’ve seen that somewhere just recently.

disk item in System Events exists at least since Leopard

Ah that’s it. Always Leopard or Snow Leopard. I ended with Jaguar.

Thanks Stefan. You share a wealth of info.