Automatically Mounting Network Shares on macOS
I have a network share that I need connected at all times on my Mac. The problem is that every time I restart my machine, I’m greeted with an error message saying it had trouble connecting to the share, even though I have it set up under Login Items.
The issue comes down to timing. Login Items try to connect before the network is fully available after a reboot, so the mount fails.
This is where automation comes into play. I chose to work with Automator, a built-in macOS application that allows users to create workflows and applications without writing code.
Creating the Application
I created an Automator application that waits for the network to stabilize before attempting to mount the share.
-
Open Automator and choose Application as the document type
-
Add a Pause action and set it to 10-15 seconds
-
Add a Run AppleScript action with the following code:
try mount volume “smb://server/sharename” on error delay 5 mount volume “smb://server/sharename” end try
Replace smb://server/sharename with your actual share path. If you’re not sure what it is, connect to the share manually, then in Finder select the mounted share and press Cmd+I : the path will be shown under “Server.”
- Save the application to your Applications folder
Adding to Login Items
-
Open System Settings → General → Login Items
-
Click the + under “Open at Login”
-
Select the Automator application you just created
Now when my Mac restarts, the Automator app launches, waits for the network to come up, and mounts the share automatically.