Direct answer
Most likely something to do with the interface. The machine keeps running after you disconnect, but the screen may lock and the display state may change, so scripts that rely on clicks and windows fail; scripts that never touch the interface are not affected.
Basis
- Screen lock: once the screen is locked, clicks and keystrokes sent through System Events do not reach the target app, and a screenshot shows the lock screen. Check the system's Lock Screen settings first, and whether the remote-access software has an option like “lock after disconnect”.
- Resolution: some remote-access software changes the remote resolution during a session to suit your local screen and restores it when you disconnect. Scripts that click by screen coordinates will then miss; locate by element name instead.
- Clipboard: during a session the local and remote clipboards may sync with each other. If the script relies on copy-then-paste, whatever you copied on your own computer during testing gets mixed in, and the behavior differs once you disconnect.
- Display sleep: after a period with no input the display goes to sleep, and some apps pause rendering their windows. Prefixing the command with
caffeinate -dkeeps the display awake while that command runs, with no system settings changed.
Boundaries: when the answer is different
If what fails is a command-line script that never touches the interface, the cause is not here; check whether the terminal window was closed, and whether environment variables exist only in the interactive terminal. Before changing system-level lock screen, login or energy settings, check with support: these settings are tied to the delivery configuration and to how the machine is recovered remotely, and changing them wholesale yourself can leave you unable to connect after a restart. Whether the machine has a display or an equivalent device attached, and what resolution the desktop has when nobody is connected, is stated in the delivery notes; we do not guarantee that every kind of UI automation works with nobody connected.
How to do it
- Have the script write a log entry before and after each step, and save a screenshot to a file when it fails.
- Disconnect, wait for the script to fail, reconnect, and see whether the screenshot shows the lock screen, a black screen or a normal desktop.
- Lock screen: check the lock options in the remote-access software and in the system, and ask support before changing system settings.
- Clicks landing off target: record the resolution before and after connecting, and change coordinate clicks to locating by element.
- Black screen or windows not refreshing: wrap the script in
caffeinate -dand try again.
Related questions
- iMessage, AppleScript and Shortcuts on a rented Mac mini: it runs, but Apple decides about your account
- Does a long Claude Code task stop when my remote connection drops?
- What usually breaks when macOS automation runs unattended for weeks?
- How to keep long tasks running on a remote Mac mini after you disconnect
- Can an AI agent control the screen and browser on a rented 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:
- Can I turn on Full Disk Access on a rented Mac to read the Messages database?
- Automation vs Accessibility permission on macOS: which does my script need?
- 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