Some server administrators set share drives to auto disconnect users after a set time of inactivity (ie fifteen minutes). As a user it’s super frustrating to connect to a server every time you need access. I’ve written an AppleScript that first checks to see if the share is mounted, if it is mounted it does nothing; however if the share is not mounted the script will auto-mount it.
Let’s first start out by downloading the script from here:
Timeout Apple Script (ZIP)
After your download is complete unzip and open the script the script (double click it to launch the OS X script editor). To being using this script you will have to know: the IP Address of the server you are connecting to, the name of the folder you want to connect to, your username, your password, and the amount of time in seconds that you want between connection attempts (idle time). All of the items in purple in the picture below are the ones you are going to need to edit (Make sure to remove all the parenthesis – completely replace everything in purple).
Once you have input all your information, go ahead and click the “Run” button to test it. If everything is working properly the share should mount. After you confirm your script is working, it is time to save it as an application:
- Go to File > Save As
- File Format: application
- Check the following Options: Run only, Stay open
- Click save
Ok, now we have an application so go ahead and drop it into your applications folder on your Mac. I have a folder under Applications called “scripts,” to help stay a little more organized. To take this to the next level, I went ahead and put it in my Login Items so that it launches when I start my Mac, and I’m immediately connected to the shares.
To add the application to the Login Items:
- Go to Applications > System Preferences
- Go to Accounts
- Go to the Login Items tab
- Finally, drag and drop your application into the Login Items list.
- Congratulations! Your computer will now auto-mount your share when you start her up, and keep you connected throughout the day.
As a side note, this script is far from perfect. When it’s running it freezes finder for a few seconds, and it must be force quit when restarting, but it’s a great solution if you do not have administrative access to the share. Have fun!