When running
tell application "System Events"
click button "Turn Bluetooth Off" of window 1 of application process "System Preferences"
end tell
I get the error:
error "System Events got an error: Can’t get application process \"System Preferences\"." number -1728 from application process "System Preferences”
I’ve also tried
tell application "System Preferences"
reveal pane "com.apple.preferences.Bluetooth"
end tell
tell application "System Events" to tell process "System Preferences"
click button 6 of window 1
end tell
quit application "System Preferences”
Didn’t give me any errors, but it didn’t work
I’m running macOS Sierra. This is supposed to turn my bluetooth off (I’m planning to have this run when I login)