heianqishi
heianqishi

Reputation: 1

How do I open Network Preferences in Mac through API?

Which API can I use to open the Network Preferences interface?

enter image description here

Upvotes: 0

Views: 693

Answers (1)

Jon
Jon

Reputation: 1479

You have several options (you didn't specify where you need to run the code). System Preferences has its own URI for opening specific panes but this seems to be working sporadically on OS 10.11 El Capitan:

open "x-apple.systempreferences:com.apple.preference.network"

You could also open the preference pane directly (System Preferences handles .prefPane bundles):

open "/System/Library/PreferencePanes/Network.prefPane"

System Preferences can also be scripted:

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.network"
end tell

or from the command line:

osascript -e 'tell application "System Preferences"' -e 'activate' -e 'set current pane to pane "com.apple.preference.network"' -e 'end'

Upvotes: 3

Related Questions