4 Replies Latest reply: Jun 11, 2013 5:31 AM by Mr.Do
Mr.Do Level 1 (10 points)



My aim is to create an applescript whereby macbook users can mount their windows home directory. These devices are BYOD so are not connected to the domain.


I have had some success but need some assistance from an expert.


The script below mounts a volume and the user is able to access their home folder. However, the volume shows the root of the pupilshare$ and I want it to show pupilshare$/username


Also, how do I get the finder window to pop up automatically once the volume has mounted, showing their home directory?


This is the information from the 'replies' debug window:


mount volume "smb://username:password@server/pupilshare$/username"

  --> file "pupilshare$:"




set username to ""

set pass to ""

set server to "server"

set share to "/pupilshare$/"


set dialogUser to display dialog "Enter your user name" default answer ""

set the username to the text returned of dialogUser


set dialogPass to display dialog "Enter your password" default answer ""

set the pass to the text returned of dialogPass


mount volume "smb://" & username & ":" & pass & "@" & server & share & username



Thanks in advance


Mac mini (Mid 2011), OS X Mountain Lion (10.8.2)
  • etresoft Level 7 (27,781 points)

    I am going to have to write a User Tip for this. For now, try using AutoFS instead: https://ssl.apple.com/business/docs/Autofs.pdf


    A simpler otption is to mount the drive manually and create a Finder alias to the network drive saving login credentials in the keychain. Then, whenever the alias gets opened, it will mount the network drive.

  • Mr.Do Level 1 (10 points)

    Thanks for your reply, not exactly what I was looking for...


    If I replace mount volume with open location then this works fine for me. A finder window opens and displays the home directory



    tell application "Finder"



    open location "smb://" & username & ":" & pass & "@" & server & share & username


    end tell

    Not content with this I now want to display the "My Documents" folder, which is within the username folder.



    set docs to "My Documents"


    tell application "Finder"



    open location "smb://" & username & ":" & pass & "@" & server & share & username & "/" & docs


    end tell



    When I run the script no volume is mounted. If I rename "my documents" in the user home folder to "mydocuments" then the volume is mounted as I require. So the issue is down to the space.

    Any ideas how to get this to work with a space in the string?



  • Hiroto Level 5 (6,700 points)



    Try replacing space with %20 such as My%20Documents.


    Good luck,


  • Mr.Do Level 1 (10 points)

    that worked brilliantly!!!!


    Thanks very much