macOS-assessment-toggle/assessment-toggle.applescript

40 lines
1.2 KiB
AppleScript
Raw Permalink Normal View History

2022-11-15 14:47:02 +00:00
script toggle
2022-11-14 19:36:22 +00:00
try
do shell script "spctl --status"
2022-11-15 14:47:02 +00:00
do shell script "spctl --master-disable" with administrator privileges
display dialog "Software assessments are disabled now!" buttons {"OK"} default button 1 with title "Information"
2022-11-14 19:36:22 +00:00
on error
2022-11-15 14:47:02 +00:00
try
do shell script "spctl --status"
display dialog "Error!" buttons {"OK"} default button 1 with title "Information"
on error
do shell script "spctl --master-enable" with administrator privileges
display dialog "Software assessments are enabled now!" buttons {"OK"} default button 1 with title "Information"
end try
2022-11-14 19:36:22 +00:00
end try
2022-11-15 14:47:02 +00:00
end script
set looping to true
repeat while looping = true
try
set spctl_status to do shell script "spctl --status"
on error
set spctl_status to "assessments disabled"
end try
if spctl_status = "assessments enabled" then
set spctl_status to "enabled"
else
set spctl_status to "disabled"
end if
set dialog_action to (display dialog "Software assessments are " & spctl_status & "!" buttons {"Exit", "Toggle"} default button 2 with title "Software Assessments Toggle")
set button_name to the button returned of dialog_action
if button_name = "Toggle" then
run toggle
else
set looping to false
end if
end repeat