« [TCC]ユーザーTCC.dbの値の操作(削除) | トップページ | [TCC]kTCCService(変更) »

[TCC]ユーザーTCC.dbの値の操作(リセット)

/usr/bin/tccutil reset は値が削除されるわけではない
『次回』アクセス時に値をセットする…そんな感じの動作です
sqlで値を『置き換え』する前に必要です

ダウンロード - usertccreset.scpt.zip

値を削除する場合はこちら
[TCC]ユーザーTCC.dbの値の操作(削除)
https://quicktimer.cocolog-nifty.com/icefloe/2022/03/post-46638b.html


#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#選択したアプリケーションの
#ユーザーTCCdbをリセットします
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


set aliasFile to (choose file with prompt "アプリケーションを選択してください" default location (path to applications folder from user domain) of type {"com.apple.application-bundle"} with invisibles without multiple selections allowed and showing package contents) as alias

tell application "Finder"
set objInfo to info for aliasFile
set strUTI to bundle identifier of objInfo
end tell

set aliasHOME to (path to home folder from user domain) as alias
set strHOME to POSIX path of aliasHOME as text

set strUserTCC to "" & strHOME & "/Library/Application Support/com.apple.TCC/TCC.db" as text

set listUserTCCcolumn to {"kTCCServiceSystemPolicyDocumentsFolder", "kTCCServiceSystemPolicyDownloadsFolder", "kTCCServiceSystemPolicyDesktopFolder", "kTCCServiceSystemPolicyNetworkVolumes", "kTCCServiceSystemPolicyRemovableVolumes", "kTCCServiceFileProviderDomain", "kTCCServiceMediaLibrary", "kTCCServicePhotosAdd", "kTCCServicePhotos", "kTCCServiceAppleEvents", "kTCCServiceFocusStatus", "kTCCServiceUserAvailability", "kTCCServiceListenEvent", "kTCCServiceSpeechRecognition", "kTCCServiceBluetoothAlways", "kTCCServiceCamera", "kTCCServiceUbiquity", "kTCCServiceLiverpool", "kTCCServiceReminders", "kTCCServiceCalendar", "kTCCServiceAddressBook", "kTCCServiceMicrophone"}

set numCntTCCcolumn to (count of listUserTCCcolumn) as number

repeat with strUserTCCcolumnName in listUserTCCcolumn

set strTccutilResetName to doReplace(strUserTCCcolumnName, "kTCCService", "")
set strCommandText to "/usr/bin/tccutil reset " & strTccutilResetName & " " & strUTI & ""
do shell script strCommandText


end repeat

to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace

|

« [TCC]ユーザーTCC.dbの値の操作(削除) | トップページ | [TCC]kTCCService(変更) »

TCC」カテゴリの記事