Automount AFP shares using Applescript

Feb 18, '05 09:53:00AM

Contributed by: billoday

I was unable to get one machine to automount due to an error code -36 when I placed aliases within Startup Items. After spending some time on the issue, I realized that the issue was related to OS X not initializing AFP before the StartupItems. I couldn't find an easy workaround for that, so I implemented an AppleScript that would do the trick for me.

You need to connect to the shares as you normally would, either by browsing to the server, or by using the "Connect To Server..." option on the "Go" menu within Finder. After all the shares have been connected, highlight all of them and make aliases of all of them. If you're lazy like me, rename them to something simple (i.e. '1', '2', etc.). To hide this implementation from the user, hide the aliases in a directory somewhere the user can't see them (I created a "server-automnt" folder on the hard drive). Write the following script (with changes for your system) in AppleScript:

delay 10
tell application "Finder" 
    open file "Macintosh HD:server-automnt:1"
    open file "Macintosh HD:server-automnt:2"
end tell
Save the script as an application, and turn off the startup screen option. Go to System Preferences. Goto Accounts. Goto Startup Items. Drag the AppleScript into the list. Reboot.

Now, you should have automounting AFP shares despite the error code.

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050215082247458