Automount SMB share at specific location

Here's my problem, I want to automatically mount a network share at a specific location without the requirement of the user entering any details. The share must be mounted in a user specific folder. Why? I have a QNAP NAS which has a share called home and that share points to a different location depending on the credentials used to access it which means that I get issues if it mounts under /Volumes as every user is mounting a home share. First in best dressed in that case as subsequent user attempts will not mount.

The drag drive to login items with credentials in keychain is nice but doesn't allow me to choose the mount location. If I use mount_smbfs from the command line to set it up as desired and then drag the share into the login items it does nothing on login.

Using the mount volume applescript command seems of little use as it doesn't allow me to specify the mount point.

The only option I could see is to use the auto_smb file examples found on the internet but this involves hardcoding passwords which I am not keen on. In a non-LDAP/AD world is this the best I can hope for to solve this issue? A non-boot alternative is to put the mount_smbfs command in a script and execute from the login items.

Ideas anyone?


I've had to do this as well, and I have an Applescript I wrote and cobbled together from working sources to request the user's password and then use mount_smbfs to mount to a specific location (with folders already set up).

This prevents stale passwords from quickly locking out the account, and also prevents passwords in the script body. I do hard-code the username in the script, that's safe enough I think.

I also do (list disks) to check which shares are already mounted, and then use the results to report back the mounted shares, and any failed mount attempts.