AppleScript partially working in 10.9.x

josaxo
New Contributor

Hello - I am wondering why the following apple script works fine in 10.8.x via manual execution and through Self Service - but in 10.9 it only works when manually executed but not through a Self Service policy?

tell application "System Preferences" reveal pane "Sharing" activate
end tell

Any pointers?
Appreciate any help.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

10.9 did introduce more strict controls over what is allowed to manipulate the GUI. Instead of a global "Enable Access for Assistive Devices" checkbox, you now need to allow access per application.
There's another thread here that details how to programmatically write in the settings to allow a specific application access to that. But since you're talking about an Applescript, not an application, I'm not certain if that's what's going for you. It could be you need to give Self Service access to the assistive devices controls. but in the interim, I would try this syntax instead and see if it works.

tell application "System Preferences"
    activate
    set the current pane to pane id "com.apple.preferences.sharing"
end tell

Also consider wrapping it up in a shell script instead of a pure Applescript. You may have better luck getting it to run.

View solution in original post

6 REPLIES 6

barnesaw
Contributor III

My guess is "Self Service.app" has been denied access to accessibility services.

josaxo
New Contributor

The strange part is that I am not receiving a prompt to allow any apps (Self Service or AppleScript) access to Accessibility Services.... and other apple scripts (that don't interact with the UI) are working fine....

mm2270
Legendary Contributor III

10.9 did introduce more strict controls over what is allowed to manipulate the GUI. Instead of a global "Enable Access for Assistive Devices" checkbox, you now need to allow access per application.
There's another thread here that details how to programmatically write in the settings to allow a specific application access to that. But since you're talking about an Applescript, not an application, I'm not certain if that's what's going for you. It could be you need to give Self Service access to the assistive devices controls. but in the interim, I would try this syntax instead and see if it works.

tell application "System Preferences"
    activate
    set the current pane to pane id "com.apple.preferences.sharing"
end tell

Also consider wrapping it up in a shell script instead of a pure Applescript. You may have better luck getting it to run.

josaxo
New Contributor

@mm2270 I attempted your syntax, but had the same results - it triggers the system preferences, but does not activate the window or open the sharing pane. I am going to try wrapping it in a shell script to see if i get better results.

mm2270
Legendary Contributor III

If it doesn't work even after wrapping it into a shell script, then you may need to resort to doing the /bin/launchctl bsexec route. I've needed to do that with quite a few scripts going forward, as the OS is getting more strict about allowing applications to be launched as the user. So we need to run commands in the context of the user's space, or it gets blocked.

josaxo
New Contributor

I ended up dropping the applescript as a .app onto the local machine, then calling it via JSS - Execute Command:
/Library/Application Support/JAMF/Scripts/OpenSharingMavericks.app/Contents/MacOS/applet

Seems to be working well! Thanks for the recommendations, much appreciated.