Direct answer
You can fix it yourself. The error means the program that launched the script has not been granted Automation permission to control the target app; turn on the matching switch under System Settings → Privacy & Security → Automation.
Basis
- Automation permission is recorded in pairs: “program A may control app B”. When you run
osascriptin Terminal, A is Terminal; launch it from a different terminal program, an editor's built-in terminal or an agent, and A has changed, so permission has to be granted again. - The system asks in a prompt the first time control happens. After you click Don't Allow it does not ask again, and every later attempt returns this error. The pair is visible in the Automation list with its switch off; turn it on.
- If the pair is not in the list at all, the script usually ran for the first time somewhere a prompt cannot appear, such as a remote-login command line or a background job. The fix is to connect to the desktop and run it by hand once in the graphical session with the same launching program, so the prompt shows.
- Errors that only started after you changed how the script is launched mostly have the same cause: the interpreter or shell the scheduled job calls is not the one you used when testing by hand.
Boundaries: when the answer is different
A common suggestion online is to reset a whole category of privacy permissions with a command. Do not do that on a rented machine: the reset also wipes other programs' records, and if the system permissions the remote-access software relies on are affected, you can lose your connection outright and have to wait for support. For the same reason, do not delete entries you do not recognize from the privacy lists. If the switch is greyed out and cannot be changed, or the same error still appears after you grant permission, send support the full error, how the script is launched and the system version so they can check; a few switches are governed by device management policy, and we do not guarantee all of them can be opened up.
How to do it
- Read the target app name in the error, and work out which program launched the script.
- Through the remote desktop, open Automation under Privacy & Security, find the launching program and expand the list of apps under it.
- If the target app is listed, turn on its switch; if not, go back to the graphical session and run the script by hand once with the same launching program.
- Click Allow in the prompt, then run it again to confirm the error is gone.
- Finally run it once through the real trigger (the scheduled job or the agent) to confirm the permission is held by the same program.
Related questions
- iMessage, AppleScript and Shortcuts on a rented Mac mini: it runs, but Apple decides about your account
- Automation vs Accessibility permission on macOS: which does my script need?
- Can an AI agent control the screen and browser on a rented Mac?
- launchd or cron: which should I use for scheduled jobs on a remote Mac?
- Can AppleScript run JavaScript in Safari or Chrome on a remote Mac?
Use case
This question belongs to the use case: iMessage, AppleScript and Shortcuts on a rented Mac mini: it runs, but Apple decides about your account
Other questions in the same use case:
- Why does my Mac script work while connected but fail after I disconnect?
- Can I turn on Full Disk Access on a rented Mac to read the Messages database?
- What am I not allowed to use a rented Mac mini for?
- Will support ever ask for my password or Apple ID?
Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support