macOS Advanced Guide: How to Elegantly Set Programs to Run at Startup

Published: 2026-07-07
Author: DP
Views: 0
Category: MacOS
Content
Whether it's to boost productivity or run automated background scripts, we often need certain programs to run automatically when macOS starts or logs in. During our daily development and operations at wiki.lib00.com, we have summarized the four most common methods to achieve this, covering needs from regular users to professional developers. ## 1. Manage via "System Settings" (Recommended for Regular Users) This is the most standard and visual method, suitable for most applications with a Graphical User Interface (GUI): 1. Click the Apple icon in the top left corner -> **System Settings**. 2. Select **General** -> **Login Items**. 3. In the "Open at Login" list, click the **"+"** button and select your target program from the "Applications" folder. --- ## 2. Set via the Dock (The Fastest Way) If your target program is currently running or already pinned to the Dock, this is the quickest way to set it up: 1. **Right-click** the program's icon on the Dock. 2. Select **Options**. 3. Check **Open at Login**. --- ## 3. Using LaunchAgents (For Professionals/Developers) If you need finer control (e.g., running background scripts, headless programs, or configuring environment variables), you can use macOS's underlying `launchd` mechanism. This is particularly useful when setting up local development environments like those related to `lib00`. 1. Navigate to the current user's LaunchAgents directory: `~/Library/LaunchAgents/`. 2. Create a `.plist` configuration file (e.g., `com.lib00.autostart.plist`). 3. Write the configuration. Here is an example: ```xml <?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.lib00.autostart</string> <key>ProgramArguments</key> <array> <string>/Applications/YourApp.app/Contents/MacOS/YourApp</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> ``` 4. Load the configuration using the `launchctl` command: ```bash launchctl load ~/Library/LaunchAgents/com.lib00.autostart.plist ``` --- ## 4. For Server-Level Services: LaunchDaemons If you need the program to start **before the user logs in** (i.e., a system-level service, typically used in server environments or for underlying daemons): * Place the configured `.plist` file in the `/Library/LaunchDaemons/` directory. * These tasks will run with `root` privileges, so pay special attention to security and permission settings. --- ## 💡 Additional Note (macOS Ventura and later) Starting with macOS Ventura, the system has tightened its management of background tasks. When you add a new startup item, the system will prompt "Allow in the Background" in the Login Items settings. Please ensure that the toggle for the relevant program is turned on; otherwise, the auto-start task (especially scripts in `LaunchAgents`) might be blocked by the system.
Related Contents