macOS Sierra - how to enable "Allow Remote Automation" using command line

Swadhikar picture Swadhikar · Jan 13, 2017 · Viewed 13.2k times · Source

I am working on an automation stuff in macOS Sierra (10.12.2). By using python's atomac support I can launch the safari browser and make the settings enabled via Safari -> Preferences -> Advanced -> check "enable Develop Menu" and then select "Develop -> Allow Remote Automation". Looks like this is not so consistent for automation perspective. I would like to know if there is any shell command to make this possible.

Allow Remote Automation screen

Answer

Montmons picture Montmons · Mar 21, 2017

Hmm ok, so as per my comment:

You could do defaults write com.apple.Safari IncludeDevelopMenu YES to activate the development menu via terminal. You could get python to execute this command for you using the subprocess module.

According to this this question it seems that one used to be able to simply do defaults write com.apple.Safari AllowRemoteAutomation 1. However, since Safari 10 this option has apparently been subjected to a higher security protocol or something (maybe because of the System Integrity Protection that was introduced). I've been looking for the plistfile that now holds the setting, but I have not been able to find it. Maybe it's not even there in an actual plistfile anymore.

I guess this leaves you with 2 options:

  1. Use apple's osascript to simulate the needed mouseclicks.
  2. Repost your question on AskDifferent or Apple's own developers forum, since you are more likely to find someone with in-depth knowledge of macOS.