Macos – Use AppleScript to change System Preferences without being visible

applescriptmacos

I would like to change settings in System Preferences without the user seeing things happen.
If I have a script that starts like:

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

the System Preference window will be shown to the user.
I'd like to know if there is a way to do it in the background somehow, or at least keep the window minimized.

(Example script can be found in this question.)

Best Solution

You might be able to do what you want with with the command line app defaults, there are some other command line apps that can manipulate other system stuff also like, pmset

Some things can be set using scripting additions also, for example the systems volumn can be set using the standard additions, you also you may be able to find other scripting additions to add more stuff.

Related Question