6 Comments

Summary:

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 […]

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:

  1. Go to File > Save As
  2. File Format: application

  3. Check the following Options: Run only, Stay open

  4. 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:

  1. Go to Applications > System Preferences
  2. Go to Accounts

  3. Go to the Login Items tab

  4. Finally, drag and drop your application into the Login Items list.
  5. 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!

  1. Very insightful and thorough post!

  2. You could also use something like Dock Dodger to keep it from appearing in the Dock. To handle quitting it, I’d personally just write another small script to quit the server script application.

  3. Canal Apple Trucos y Utilidades – » Reconecta automáticamente discos de red Thursday, May 15, 2008

    [...] de redes desconectan los discos en red tras un periodo de inactividad, este script que The Apple Blog nos trae te ayuda a mantenerlos conectados. El script primero ve si el disco está apropiadamente [...]

  4. I personaly use more or less the following command line as cron job:
    osascript -e “mount volume “smb://user:pass@ip/name””

    With the Login Items, I think the drive will never get connected if the server is down at the time of login, which is definitely an issue for me (my NAS is not always on).

  5. Jenny, thank you very much for this easy solution. Has Apple been given feedback? Why can’t this be an option in Finder? Thanks.

  6. Opsætning af Mac for en kunde.. | danielbahl.dk Tuesday, August 19, 2008

    [...] er et tip til automatisk at remounte Windows SMB shares efter genstart (Link) Apple, file-sharing, Leopard, smb, [...]

Comments have been disabled for this post