ダウンロードしたアプリケーションの実行許可にすべてのアプリケーションを許可を表示/非表示(Gatekeeper)

ダウンロードしたアプリケーションの実行許可にすべてのアプリケーションを許可を表示/非表示(Gatekeeper)するAppleScriptです。
変更を反映するため、システム環境設定が起動または再起動されます。

macOS Big Sur 11.6、iMac (Retina 5K, 27-inch, 2019)で作成・動作確認しています。
try
set status to do shell script "spctl --status"
if status is "assessments enabled" then
do shell script "spctl --master-disable" with administrator privileges
try
set status2 to do shell script "spctl --status"
if status is status2 then return
end try
openSystemPreferences("General", "com.apple.preference.security") of me
end if
on error msg
if msg is "assessments disabled" then
do shell script "spctl --master-enable" with administrator privileges
try
set status2 to do shell script "spctl --status"
if status2 is "assessments enabled" then
openSystemPreferences("General", "com.apple.preference.security") of me
end if
end try
end if
end try

on openSystemPreferences(anAnchor, paneID)
if application "System Preferences" is running then quit application "System Preferences"
delay 0.2

tell application "System Preferences"
launch
--activate
reveal anchor anAnchor of pane id paneID
end tell
end openSystemPreferences
macOS Sonoma 14.3.1で動作確認したもの
try
set status to do shell script "spctl --status"
if status is "assessments enabled" then
do shell script "spctl --master-disable" with administrator privileges
try
set status2 to do shell script "spctl --status"
if status is status2 then return
end try
openSystemPreferences("Security", "com.apple.settings.PrivacySecurity.extension") of me
end if
on error msg
if msg is "assessments disabled" then
do shell script "spctl --master-enable" with administrator privileges
try
set status2 to do shell script "spctl --status"
if status2 is "assessments enabled" then
openSystemPreferences("Security", "com.apple.settings.PrivacySecurity.extension") of me
end if
end try
end if
end try

on openSystemPreferences(anAnchor, paneID)
if application "System Settings" is running then
quit application "System Settings"
delay 1
end if

tell application "System Settings"
reveal anchor anAnchor of pane id paneID
activate
end tell
end openSystemPreferences

更新履歴

inserted by FC2 system