If you’re a Mac user who relies on network drives (like a NAS, a Windows share, or a server), you’ve almost certainly felt the frustration: you put your Mac to sleep, change Wi-Fi networks, or your server reboots, and suddenly your network drives are gone. You have to open Finder, go to “Connect to Server,” and manually mount them all over again.
It’s a small annoyance, but when you have to do it multiple times a day, it becomes a significant drag on productivity. macOS’s built-in “Login Items” feature only works at login and doesn’t help with mid-session disconnects.
After a long and detailed debugging journey, I’ve developed a simple, robust, and “set-it-and-forget-it” solution. Today, I’m sharing this package of scripts that creates a persistent background agent to ensure your network drives are always there when you need them.

✨ What Makes This Solution Different?
This isn’t just another simple script. It has been designed from the ground up to be reliable and user-friendly, solving the common pitfalls of other solutions.
- ⚙️ A Reliable Engine: It uses AppleScript to command the Finder directly, the same method you use when manually connecting. This is far more compatible than low-level commands that often fail with special characters or permissions issues.
- 🚀 Truly Persistent: A background agent runs every 30 seconds. It doesn’t just mount drives at login; it actively checks and remounts them whenever they disconnect, for any reason.
- 📝 Simple & Clean Configuration: No more confusing URL encoding! You configure your drives in a simple, 4-column text file that’s easy to read and edit.
- 🔔 Smart Notifications: If a drive genuinely can’t be reached (maybe the server is offline), the script will notify you once and then wait, preventing a storm of annoying pop-ups.

🚀 The Setup Guide
Getting this up and running is a straightforward, one-time process.
Step 1: Download the Script Package
First, you need to get the files. I’ve hosted the entire package on GitHub to make it easy to access.
- Download macOS Drive Mounter from GitHub here (<– My GitHub repository link!)
Download the ZIP file and extract it to a permanent location on your Mac. A great place for it is in your Documents folder, inside a subfolder like Scripts.
Step 2: Configure Your Drives
Before we activate the script, we need to tell it which drives to mount.
- Open the drives.txt file in a text editor.
- You’ll see a well-commented file with examples. Replace the generic examples with your own server details.
The format is a simple, 4-column layout:
server_address “Share Name” username “Password”
Crucial Tip: If your Share Name or Password contains spaces or any special characters (like @, !, $, #), you must enclose it in “double quotes”.
Here are some examples of what it should look like:
# Example 1: Simple share on a NAS using its hostname
MyNAS.local Public guest ""
# Example 2: Share with a space in its name, using an IP address
192.168.1.50 "My Documents" myuser "SimplePass123"
# Example 3: Share with a special character (@) in its name
fileserver.local "Scans@HP" scanner "Scan-Pass!"
# Example 4: Password with special characters that requires quotes
10.0.0.10 Backups admin "My$uperP@ssw0rd!"
Step 3: Install the Background Service
Now it’s time to activate the script using the Terminal.
- Open the Terminal app (you can find it in Applications/Utilities).
- Navigate to the folder where you saved the script. For example:
cd ~/Documents/macOS-Drive-Mounter
- Next, make the scripts executable by running this command:
chmod +x *.sh
- Finally, run the installer:
./install.sh
Step 4: Approve the One-Time Security Prompts
The very first time the script runs, macOS will ask for your permission to let it control the Finder and connect to servers. This is a normal and essential security step.
- You will likely see a prompt asking for permission to control the Finder. Click “Allow.”
- For each new server, you may see a connection confirmation prompt. Click “Connect.”
Once you have approved these, macOS will remember your choices, and the script will run silently and automatically from now on.
✅ And you’re done! Your network drives will now mount automatically at login and will diligently reconnect whenever they are disconnected.
🗑️ How to Uninstall
If you ever want to remove the script, it’s just as easy.
- Navigate to the script’s folder in the Terminal.
- Run the uninstaller script:
./uninstall.sh
- You can then safely delete the folder.
A Final Word
This project was a deep dive into the nuances of macOS scripting, from the quirks of the mount command to the complexities of background agent permissions. I hope this tool saves you from the daily annoyance of reconnecting your drives and makes your workflow a little smoother.
You can find the complete source code and all the files on the GitHub repository. If you have any questions or feedback, feel free to leave a comment below.
0 Comments