Prevent app Starting on macOS

on Sun Nov 24 | Updated on Sun Nov 24

Turn on/off Guest On Mac OS

sudo sysadminctl -guestAccount on
sudo sysadminctl -guestAccount off

alias gon=”sudo sysadminctl -guestAccount on”
alias gof=”sudo sysadminctl -guestAccount off”

Prevent Setup Assistant.app from Starting on macOS

If you want to stop Setup Assistant.app from running on macOS, here’s an improved method using a custom script and a LaunchAgent.

Step 1: Create a Custom Script

Save the following script as prevent_setup_assistant.sh in /usr/local/bin/:

#!/bin/bash

# Check if Setup Assistant is running and terminate it
while true; do
    pgrep -f "Setup Assistant.app" && pkill -f "Setup Assistant.app"
    sleep 1
done

Make the script executable:

chmod +x /usr/local/bin/prevent_setup_assistant.sh

Step 2: Create a LaunchAgent

Create a LaunchAgent file in ~/Library/LaunchAgents/ (or /Library/LaunchAgents/ for all users) named com.prevent.setupassistant.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.prevent.setupassistant</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/prevent_setup_assistant.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

Step 3: Load the LaunchAgent

Run the following command to load the LaunchAgent:

launchctl load ~/Library/LaunchAgents/com.prevent.setupassistant.plist

Optional: Restrict Execution

To enhance security, make the files accessible only to the root or admin user:

sudo chmod 600 /Library/LaunchAgents/com.prevent.setupassistant.plist
sudo chmod 700 /usr/local/bin/prevent_setup_assistant.sh

With this setup, Setup Assistant.app will be terminated as soon as it starts.