Join me on an adventure in discovering how to use scripts to open nearly every single aspect of the macOS System Preferences Pane!
Mac admins and developers may at some point in their careers find themselves needing to script the opening of macOS System Preferences panes, either for automation or other tasks like presenting a specific pane to a user to click or configure.
The URL Scheme introduced in 10.10 (and refined/restricted in 10.11) makes it easy to not only open specific System Preference Panes, but to deep link to specific sections of those panes with precision. Apple seems to be adding new urls and anchors to System Preferences with each macOS release, so this will continue to be a useful tool to have in your macadmin tool belt.
So how can you automatically open specific System Preferences panes in your scripts? I’m glad you asked! Let’s dive in…
System Preferences – Security & Privacy
Since the System Preferences pane that admins seem most interested in is Security & Privacy, I’ll focus on that here. If you’d like to explore additional panes beyond Security & Privacy, I’ve compiled a complete list of macOS 12 Monterey panes here.
Let’s start with the simplest one. How do I just open the System Preference Pane? As with all things computers, there’s multiple ways to accomplish that task.
You could use the standard open command:open "/System/Applications/System Preferences.app"
You could use AppleScript:osascript -e 'tell application "System Preferences"' -e 'activate' -e 'end tell'
Or you can use the the open command with a valid URLScheme that we’ll be covering in this post:open "x-apple.systempreferences:com.apple.preferences"
Opening specific System Preferences Panes
If you want to open the specific Security & Privacy Pane in System Preferences, we can call that pane using the url scheme:open "x-apple.systempreferences:com.apple.preference.security"
Now this is a great start, but oftentimes we want to deep link to specific section of this pane. What if I want to direct someone to approve Screen Recording for Zoom (Privacy_ScreenCapture
)? Or direct them to their Camera (Privacy_Camera
) and Microphone (Privacy_Microphone
) settings. As of this post, Apple does not allow MDMs to control or configure any of those settings, and so if as an admin you want to ensure those items are checked on an employee’s first day BEFORE those permissions are required (I’d like to avoid having someone hop into their first onboarding Zoom call, only to have to exit, navigate System Preferences, turn on microphone, camera, and screen recording, and then re-join the meeting). Your goal as an admin is to make that user experience as easy as possible.
Below I’ve included every single url link to every part of the Security & Privacy pane in System Preferences.
System Preferences
Deep Linking to all Security & Privacy Panes
General Tabopen "x-apple.systempreferences:com.apple.preference.security?General"
FileVault Tabopen "x-apple.systempreferences:com.apple.preference.security?FDE"
Firewall Tabopen "x-apple.systempreferences:com.apple.preference.security?Firewall"
Privacy Tab
If you want to automatically prompt the user to unlock any of the panes for editing, you can do so using open "x-apple.systempreferences:com.apple.preference.security?Advanced"
- Location Services:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_LocationServices"
- Contacts:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Contacts"
- Calendars:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars"
- Reminders:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Reminders"
- Photos:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Photos"
- Camera:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Camera"
- Microphone:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone"
- Speech Recognition:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_SpeechRecognition"
- Accessibility:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"
- Input Monitoring:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent"
- Full Disk Access:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"
- Files and Folders:
unknown - Screen Recording:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
- Media & Apple Music:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Media"
- HomeKit:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_HomeKit"
- Bluetooth:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Bluetooth"
- User Availability:
unknown - Automation:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Automation"
- Developer Tools:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_DevTools"
- Analytics & Improvements:
unknown - Apple Advertising:
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Advertising"
One thing to keep in mind: Only Panes that have NSPrefPaneAllowsXAppleSystemPreferencesURLScheme
in their info.plist can be opened via url scheme. If you’re trying to use a url scheme and find it’s not working, be sure to identify that the pane supports a URL scheme.
Things to watch out for:
Note that some panes start with com.apple.preference.
and some start with com.apple.preferences.
, why is that? I have no clue, but if you are hunting and guessing at url schemes, don’t let it trip you up.
This url schemes listed here are for macOS Monterey. You may have limited success with older operating systems depending on how much System Preferences has changed between operating system versions and if those panes previously supported UrlScheme or not.
I’ve recorded ALL of the urlschemes supported on macOS Monterey over Github, so head there for the complete list.
Hope this was helpful! Happy scripting!
One thought on “Scripting System Preferences Panes”
Comments are closed.