display dialog "This script allows you to run applications from anywhere on macOS Sierra, recommended for advanced Mac users only." buttons {"Allow from anywhere", "Revert to Default", "Cancel"} with title "macOS Sierra Gatekeeper"
set the button_pressed to the button returned of the result
if the button_pressed is "Allow from anywhere" then
display dialog "Allow from anywhere will let you run any application, no matter the source and will disable Gatekeeper. This requires administrator privileges." buttons {"Continue", "Cancel"} with title "macOS Sierra Gatekeeper"
if the button returned of the result is "Continue" then
tell application "System Preferences" to quit
delay 1
try
do shell script "spctl --master-disable" with administrator privileges
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.security"
end tell
on error errMsg number errNum
display dialog "Couldn't run without administrator privileges." buttons {"Ok"} with title "macOS Sierra Gatekeeper" default button 1
end try
end if
else if the button_pressed is "Revert to Default" then
display dialog "Revert to Default will enable Gatekeeper and will only let you run applications from the App Store and identified developers only. This requires administrator privileges." buttons {"Continue", "Cancel"} with title "macOS Sierra Gatekeeper"
if the button returned of the result is "Continue" then
tell application "System Preferences" to quit
delay 1
try
do shell script "spctl --master-enable" with administrator privileges
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.security"
end tell
on error errMsg number errNum
display dialog "Couldn't run without administrator privileges." buttons {"Ok"} with title "macOS Sierra Gatekeeper" default button 1
end try
end if
end if
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.