How do I open the System Preferences Panel on a particular tab?

Hi,
How do i open the System Preferences Panel on a particular tab?

Shell1.Execute ("/usr/bin/open -b com.apple.systempreferences /System/Library/PreferencePanes/Security.prefPane")

“Security.prefPane**?Privacy**” seems to no longer work.
Thanks

Use AppleScript.
E.g. in ScriptEditor use

tell application "System Preferences" to get panes

to get a list of alla available panels.
Now you can navigate to a specific panel with a name like

tell application "System Preferences" to reveal pane id "com.apple.preference.displays"

In case you want to still use the shell you may use e.g.

osascript -e 'tell application "System Preferences" to activate' -e 'tell application "System Preferences" to reveal pane id "com.apple.preference.displays"'

Using

System.GoToURL("x-apple.systempreferences:com.apple.preference.security?Privacy_Automation")

works fine.

1 Like

A third way:

dim f as folderItem = SpecialFolder.System.child("Library").child("PreferencePanes").child("Security.prefPane")
if f <> nil and f.exists then
  dim sh as new shell
  sh.Execute "open " + f.ShellPath
end if
1 Like

This is what I use. You can call the prefPane directly and the system will do the right thing.

Also, I just tried your command in my Terminal (macOS 12.3.1) and it works fine:
/usr/bin/open -b com.apple.systempreferences /System/Library/PreferencePanes/Security.prefPane

@Mike_D @Tim_Jones Does this technique make Apple Security complain that you’re trying to access a folder in /System/Library?

I learned the way @Beatrix_Willius shared, and somewhere buried in my reference notes is a list of the different locations that are valid.

1 Like

Good point: for me it does not cause a security warning, but I have previously set Terminal with Full Disk Access…

I was provided this amazing reference by Norman

4 Likes

Yes it’s work fine but, i want open to a SPECIFIC tab ! Sample : “General” tab, “Filevault” tab, “Firewall” tab or “Privacy” tab.
Thanks

part 1 : Absolutely not.

1 Like

Thanks you very much work fine ! But how do I get the names of the other tabs? FileVault, Firewall and General tab?
Where do we find the list?

The document linked above has an answer for you: https://gist.github.com/rmcdongit/f66ff91e0dad78d4d6346a75ded4b751#security–privacy-pane

1 Like

I found it!
https://www.mbsplugins.de/archive/2020-04-05/MacOS_System_Preference_Links
Thanks

Thank you @Denis_DUBOIS & @Beatrix_Willius, this is very useful.

I wanted to be able to open the General > Languages & Region pane, but com.apple.Localization is listed as not usable with System.GoToURL. Also tested in code that it doesn’t work.

So I experimented and combined x-apple.systempreferences: & com.apple.Localization together and it works :grin:

System.GotoURL("x-apple.systempreferences:com.apple.Localization")