Here’s a approach to run a script as a LaunchAgent so that it’s going to bypass TCC restrictions. I’ve examined this technique and it really works for me. Reference: MacOS Shortcut scheduling utilizing launchctl
Step 1
In System Settings > Privateness & Safety > Information & Folders, be certain that the Shortcuts app has full entry. Relying on what the script does, you may additionally want to present it entry within the Full Disk Entry panel.
Step 2
In Shortcuts, create a shortcut that runs your script, and take a look at it. See the built-in assist if wanted. Give the shortcut a novel title, corresponding to “Instance”.
Step 3
Create a file in ~/Library/LaunchAgents
with a novel title and the filename extension .plist
. I will use the title shortcut.plist
.
Beneath is a recommended template for the file ~/Library/LaunchAgents/shortcut.plist
:
Label
instance.shortcut
ProgramArguments
/bin/sh
-c
/usr/bin/shortcuts run "Instance"
StartCalendarInterval
Hour
13
Minute
15
This file will likely be loaded routinely as a job by launchd
.
For the worth of the Label
key, use a novel label (not essentially the identical because the filename.)
Within the ProgramArguments
array, specify the title of the shortcut you created in Step 2. Right here I’ve used “Instance”.
There are two methods to specify a price for the important thing StartCalendarInterval
. If you need the job to run solely at one common interval, use a dictionary of integers, as within the above template. If you wish to specify greater than interval, use an array of dictionaries. See the launchd.plist(5)
man web page for particulars.
If the system is shut down or asleep when the job is scheduled to run, it is going to run as quickly as doable when the system is woke up.
Step 4
The job ought to load routinely, however to ensure, enter this command in a shell:
launchctl load ~/Library/LaunchAgents/shortcut.plist
To cease the job from working, enter:
launchctl unload ~/Library/LaunchAgents/shortcut.plist
and take away the file. You will need to additionally unload after which reload the file after making any adjustments.