script toggle try do shell script "spctl --status" do shell script "spctl --master-disable" with administrator privileges display dialog "Software assessments are disabled now!" buttons {"OK"} default button 1 with title "Information" on error 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 end try 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