77 Replies
      Latest reply on Jul 19, 2017 4:55 AM by SkySpirit
      Tweak Level 1 Level 1 (10 points)

        I have a little Script as Startup-Object:

        https://picload.org/image/rrrpioli/bildschirmfoto2016-07-06um17.3.png

         

        In this Script 2 Shares from my NAS (nas.box) and a Raspberry Pi (Raspi3) should mounted on Startup. This worked with El Capitan without problems. Since macOS Sierra Beta 1 the Script loads and mounting starts after startup but  asks for my Login-Data. Username an Passwords are filled, but i must click on "Connect". For the NAS-Share, the Option to store the Login-Data to Keychain is checked. On the Raspberry-Share it's not checked, but the User-Data are also filled.

         

        https://picload.org/image/rrrpioli/bildschirmfoto2016-07-06um17.3.png

         

        https://picload.org/image/rrrpiolw/bildschirmfoto2016-07-06um17.3.png

         

        The Problem is, that this occours every time, when i reboot my Mac or Logout/Login to my User-Account. I've tried to delete the Objects from Keychain, but it doesent change anything.

         

        Any suggestions?

        • Re: macOS Sierra Automount on Startup
          Tweak Level 1 Level 1 (10 points)

          still happens on Beta 3. I have deleted the Login-Data from Keychain and added these again. When i reboot the Mac, i must manually click to connect. Any ideas, why the stored Username/Password is filled, but the volumes not autmatic connect?

            • Re: macOS Sierra Automount on Startup
              alexk403 Level 1 Level 1 (0 points)

              What does your script look like? If it is by chance a bash script, then I might know your problem. I too have a bash script set as a login item that mounts my network drive, but doesn't work as of sierra.

                • Re: macOS Sierra Automount on Startup
                  Tweak Level 1 Level 1 (10 points)

                  This is my script, saved as application:

                   

                   

                  tell application "Finder"

                    try

                    mount volume "afp://nas.box/SHARE1" as user name "USERNAME"

                    mount volume "afp://nas.box/SHARE2" as user name "USERNAME"

                    mount volume "smb://pi:PASSWORD@raspi3.local/RasPi3/"

                    end try

                  end tell

                   

                   

                  tell application "Dropbox"

                    activate

                  end tell

                    • Re: macOS Sierra Automount on Startup
                      KillerBob Level 1 Level 1 (0 points)

                      For what it is worth, I have exactly the same problem in Sierra dev beta 7 (16A304a). My script looks like this:

                       

                      mount volume "afp://BMK-rnp (AFP)._afpovertcp._tcp.local/Data"

                       

                      This works fine from my OSX El capitan machines, but not my macOS Sierra machines. It comes up asking to confirm username and password, eventhough I have asked it to be saved in Keychain. Also, I blew away my Login Keychain, and it is still a problem.

                        • Re: macOS Sierra Automount on Startup
                          iMachine Level 1 Level 1 (0 points)

                          Same problem here in dev preview 7. My script essentially does the same thing - mounts a series of NAS shares but on my macbooks it runs a loop that checks for a specific wifi SSID and only tries to connect the shares when that wifi is present. It's always running in the background at startup and it's so quiet I forget about it. It's been working great since Mavericks but now asks to confirm (user name and password already filled) every time I boot up the mac pros or open the macbook lids.

                           

                          The real problem for me is that I have a different version of the script running at startup on a group of headless mac pros. Now I have to remote into each one and click a few times (once for each NAS)  and remember to do this each and every time they boot up.

                           

                          Here's the macbook version of the script:

                           

                          repeat

                           

                            set WifiCHECK to "WIFI_SSID"

                            set theList to paragraphs of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk '{print $1}'")

                            if theList contains WifiCHECK then

                           

                            set serverAddress1 to "smb://USERNAME:PASSWORD@IP_ADDRESS/SHARE_FOLDER1"

                            set serverVolume1 to "SHARED_FOLDER1"

                            tell application "Finder"

                            try

                            if disk serverVolume1 exists then

                            else

                            with timeout of 3 seconds

                            mount volume serverAddress1

                            end timeout

                            end if

                            end try

                            end tell

                           

                            set serverAddress2 to "smb://USERNAME:PASSWORD@IP_ADDRESS/SHARE_FOLDER2"

                            set serverVolume2 to "SHARE_FOLDER2"

                            tell application "Finder"

                            try

                            if disk serverVolume2 exists then

                            else

                            with timeout of 3 seconds

                            mount volume serverAddress2

                            end timeout

                            end if

                            end try

                            end tell

                           

                            end if

                           

                            delay 10

                           

                          end repeat

                            • Re: macOS Sierra Automount on Startup
                              KillerBob Level 1 Level 1 (0 points)

                              This was NOT fixed in the GM version. I have filed bug-reports, I have reported this everever I can, and I see I am not alone. Can someone please find a fix, and can Apple please take this seriously...

                              • Re: macOS Sierra Automount on Startup
                                SkySpirit Level 1 Level 1 (0 points)

                                Hello. Can you help me to combine Auto VPN and then mount drive? VPN on idle set vpn_name to "'VPN'" tell application "System Events" set rc to do shell script "scutil --nc status " & vpn_name if rc starts with "Disconnected" then do shell script "scutil --nc start " & vpn_name end if end tell return 10 end idle NAS tell application "Finder" try mount volume "afp://10.0.1.10/Public" mount volume "afp://10.0.1.11/Public" end try end tell return 10 tell application "Finder" activate end tell Thanks

                        • Re: macOS Sierra Automount on Startup
                          mkleinb Level 1 Level 1 (0 points)

                          I use AutomountMaker, which is a great program to mount you shares, but experience the same problem. I get the popup “Enter your name and password for the server….” every time. Name and Password are fortunately pre-filled and although I check “Remember this password in my keychain”, I get the popup every time I mount my shares, although it is stored in my keychain. Already filed a bug report and hopefully it will be resolved soon...

                        • Re: macOS Sierra Automount on Startup
                          Juerg Level 1 Level 1 (0 points)

                          A workaround is to mount the smb shares to a folder in your home directory.

                           

                          Apple Script / Shell Script:

                           

                          do shell script "[ ! -d ~/MyNASVolumes/share-to-mount ] && mkdir -p ~/MyNASVolumes/share-to-mount || echo directoryOK"
                          do shell script "mount -t smbfs //NAS-user:NAS-user-password@myNASServer/share-to-mount ~/MyNASVolumes/share-to-mount"
                          • Re: macOS Sierra Automount on Startup
                            tnaseem Level 1 Level 1 (0 points)

                            Add me to the list of people having the same issue. MacOS Sierra GM.

                             

                            I did exacly what you lot have done - wiping my keychains in their entirety on both machines that I have automount scripts running. No dice, of course.

                             

                            Terribly annoying.

                            • Re: macOS Sierra Automount on Startup
                              nidr0x Level 1 Level 1 (0 points)

                              Same problem since beta 1 and now in GM

                              • Re: macOS Sierra Automount on Startup
                                Franco Level 1 Level 1 (0 points)

                                I used all sierra Beta and they all worked for me (in fact it work since many OS ago, but before, MacOS X server had better option to allow this)

                                Once the drive is on the desktop, i drop it into my account in User and Group -> Login items

                                that is it, no script, all my network drives just mount every time I open my account

                                  • Re: macOS Sierra Automount on Startup
                                    qahtani Level 1 Level 1 (0 points)

                                    I'm doing the same as you, and have been since I first started using OS X in 2002.

                                     

                                    However, in Sierra I am prompted for a username/password for my shares with the fields pre-populated — just like the other posters.  They seem to be using scripts, but I think the underlying problem is identical.

                                  • Re: macOS Sierra Automount on Startup
                                    TomBurke Level 1 Level 1 (0 points)

                                    I have the same problem but a work around for me is create another program that just hits the enter key for me when the other is started i know its not practical but its all I got right now i would have done it in the one program but idk how to create 2 threads because a script goes line by line so by trying to have the enter key after mount drive wont work because its waiting for mount drive to finish!

                                     

                                    set IP_Valid to true

                                    set networkName to "NETGEAR78-5G"

                                    set IP_address to "192.168.1.xxx"

                                    set val to true

                                    set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"

                                    try

                                       --check if address can ping

                                      do shell script ("ping -c 2 " & IP_address)

                                    on error

                                      set IP_Valid to false

                                      set val to false

                                    end try


                                    --check if your network exists

                                    if SSID is not networkName then

                                      tell application "EnterKey" to quit

                                    end if

                                    tell application "System Events"

                                      try

                                      delay 3

                                      key code 76 -- enter key

                                      set val to false

                                     

                                      on error

                                      --display dialog "NO ENTER with icon stop

                                      end try

                                    end tell

                                    if val = false then

                                      tell application "EnterKey" to quit

                                    end if

                                    • Re: macOS Sierra Automount on Startup
                                      arimuras Level 1 Level 1 (0 points)

                                      Still problem. 10.12.1 Beta(16B2327e)

                                      • Re: macOS Sierra Automount on Startup
                                        jospic Level 1 Level 1 (0 points)

                                        Apple have locked down the /Volumes folder as confirmed here:

                                         

                                        https://openradar.appspot.com/radar?id=4948585099558912

                                         

                                        There are not workaround....

                                         

                                        -j

                                        • Re: macOS Sierra Automount on Startup
                                          evalenzb Level 1 Level 1 (0 points)

                                          Hi all,

                                          I have the very same problem with actual macOS final release for Sierra, 4 iMac, 3 Macbook, and 2 Mini (for server purposes).

                                           

                                          Servers are the most problematics, please Apple help fix it!

                                          • Re: macOS Sierra Automount on Startup
                                            rene b Level 1 Level 1 (0 points)

                                            Confirmed; same issue here in Sierra 10.12 public release, and also when using the utility "Drive Mounter".

                                            • Re: macOS Sierra Automount on Startup
                                              biker.2011 Level 1 Level 1 (0 points)

                                              Same Here. Apple is all about Security these days. But this is a feature Apple need to fix. Many business customers will complain about this ****.

                                              • Re: macOS Sierra Automount on Startup
                                                donrico Level 1 Level 1 (0 points)

                                                I have a Synology that goes to sleep at night and normally the mount volume command will do the trick to reconnect the share after my Synology wakes.
                                                Since MacOS sierra it is necessary to click the button connect with the given credentials.

                                                 

                                                I made a temporary solution that will autoconnect the share, but you'll have to make two applescripts.

                                                 

                                                Script 1: Connect the share

                                                ===

                                                tell application "Finder"

                                                    try

                                                        mount volume "smb://username:password@networklocation/sharename"

                                                    end try

                                                end tell

                                                ===

                                                 

                                                Script 2: Hitting the return button

                                                ===

                                                tell application "System Events"

                                                    keystroke return

                                                end tell

                                                ===

                                                 

                                                After you made the two scripts you have to make 2 calendar items.

                                                Open Calendar and create a new event.

                                                Pull down the menu next to “Alert” and choose “Open File” now choose the first script.

                                                 

                                                Make a second event (just one minute later) and choose the second script.
                                                Basically the first script will run at the selected time and will be waiting for the return button that will arrive one minute later.

                                                 

                                                This way it's automated again. And you can copy the events to another day. It's not a clean solution but it works for me until Apple comes with a update / solution.

                                                • Re: macOS Sierra Automount on Startup
                                                  Amarand Level 1 Level 1 (0 points)

                                                  Having the same issue with 10.12 (16A323).  It's super annoying that shares cause a "Connect As" window to pop-up, with pre-populated Name and Password fields, and I have to manually press Connect. This is wreaking havoc with my scripts and backup utilities.  Never had this issue with previous versions of the OS.

                                                  • Re: macOS Sierra Automount on Startup
                                                    Atarimac Level 1 Level 1 (10 points)

                                                    Here is how I am dealing with it.

                                                     

                                                    Go to your home folder ~ and create a folder named Server.  Open the newly created Server folder and make another folder named Drive.

                                                     

                                                    Then launch Applescript Editor and create a new script like so:

                                                     

                                                    do shell script "mount_afp afp://user:password@ip_address/Drive ~/Server/Drive"

                                                     

                                                    You will need to enter your particulars here.  Example : "mount_afp afp://bob:xyz123@192.168.1.100/bob ~/Server/Drive"

                                                     

                                                    Save your script as an application.

                                                     

                                                    Open System Preferences - User & Groups - Login Items.  Drag your script application into the box for automatic login items.  Reboot.

                                                     

                                                    Your drive should be on your desktop.

                                                     

                                                    Good luck.

                                                      • Re: macOS Sierra Automount on Startup
                                                        albanet78 Level 1 Level 1 (0 points)

                                                        "Hi @Atarimac

                                                         

                                                        I'm a bit of confused. Where should I create the "folder named Server" ? What home are you talking about ? The NAS one or on the mac ?

                                                         

                                                        Excuse my misunderstandment but I'm really annoyed by this new "feature" and I'm absolutely not familiar with developpement.

                                                         

                                                         

                                                        regards.

                                                          • Re: macOS Sierra Automount on Startup
                                                            Atarimac Level 1 Level 1 (10 points)

                                                            You create the folder in your home folder of your Mac's hard drive.  Double click on your Mac's hard drive.  Then double click on users.  Click on the icon of a house (your user name should be under the house).  Navigate to the menu bar.  Choose File.  Then New Folder.  Name the new folder Server.  Double click the new folder named Server.  Then navigate to the menu bar. Choose File.  Then New Folder.  Name the new folder Drive.  Close out all of the windows.

                                                              • Re: macOS Sierra Automount on Startup
                                                                albanet78 Level 1 Level 1 (0 points)

                                                                HI @atarimac

                                                                 

                                                                Thanks for your reply but I can't get it to work.

                                                                 

                                                                I've created the folders where you told but I don't understand how it can "find" the NAS shares.

                                                                Plus the script returns me a number 2 error.

                                                                What credentials and what IP should I write ? The NAS's ones ? or the Mac's one ?

                                                                 

                                                                 

                                                                In fact none of the above soutions works for me..

                                                                 

                                                                 

                                                                I'm desperate...

                                                                 

                                                                Anyway thanks all for all the solutions.

                                                                  • Re: macOS Sierra Automount on Startup
                                                                    Tylast Level 1 Level 1 (0 points)

                                                                    I get the same error using the mount_afp command.  Figure that one out yet?

                                                                     

                                                                    I also get the following error when trying to use the mount smbfs command as well:

                                                                    error "usage: mount [-dfruvw] [-o options] [-t external_type] special node
                                                                           mount [-adfruvw] [-t external_type]
                                                                           mount [-dfruvw] special | node" number 1
                                                                    

                                                                     

                                                                    Any ideas?

                                                              • Re: macOS Sierra Automount on Startup
                                                                IMEI Level 1 Level 1 (0 points)


                                                                @Atarimac

                                                                 

                                                                Thank you for the hint

                                                                This works for me  ->          mount -t afp afp://user:pass@192.168.1.100/Data ~/Server/Drive

                                                                • Re: macOS Sierra Automount on Startup
                                                                  albanet78 Level 1 Level 1 (0 points)

                                                                  Finally I got it working with your solution!

                                                                   

                                                                  After re-reading the whole thread 2 times, I now understand how it's supposed to work!

                                                                   

                                                                  So I'll answer myself and explain it for people like me :

                                                                   

                                                                  I did create those two folders like you said 3server" and "Drive" and I wrote exactly this script :

                                                                   

                                                                  do shell script "mount_afp afp://NASusername:NASpassword@NASIPadress/NAMEoftheVolumeinNAS ~/Server/Drive"

                                                                   

                                                                  As i Have several volumes in my NAS, I struggleded a little more when I had the idea to launch my originial mounting script and it now works perfectly !!

                                                                   

                                                                  So to be clear, i launch the first script as a Sierra credential and the second as it was already to mount all my drives (10 in my case).

                                                                   

                                                                  A huge thanks to everyone over here !!

                                                                   

                                                                  alban

                                                                  • Re: macOS Sierra Automount on Startup
                                                                    TECreasey Level 1 Level 1 (0 points)

                                                                    Thank you so much for this solution. I have been trying to find a perfect solution to mounting a network drive at login and this is the best one yet. I have been so frustrated having to enter the same username and password over and over. For some reason it never remembered my credentials and now it does.

                                                                     

                                                                    Thank you.

                                                                    • Re: macOS Sierra Automount on Startup
                                                                      DerRudi Level 1 Level 1 (0 points)

                                                                      Yes I can confirm this works... you have to use the IP adres of the shares... not the existing links you have been using so far...

                                                                      • Re: macOS Sierra Automount on Startup
                                                                        ppoisson Level 1 Level 1 (0 points)

                                                                        on macOs 10.12.2 same issue with getting prompted for a username and password even though I added it to my keychain, but changing the mount point worked. I noticed the mounts still show up in /Volumes even though I instructed them to go to /Users/machome/Mounts? Not too sure how it knows they are mounted even though I have it check my new Mount folder?

                                                                         

                                                                        tell application "Finder"
                                                                          if not (disk "/Users/machome/Mounts/views" exists) then
                                                                          mount volume "smb://network_machine/viewes
                                                                          end if
                                                                        end tell
                                                                        
                                                                      • Re: macOS Sierra Automount on Startup
                                                                        ticky Level 1 Level 1 (0 points)

                                                                        I am using the Users & Group Login Items built-in function to automatically mount a drive on startup and I am having this issue above. It seems unreasonable that Apple would change the security settings to prevent mounting by its own system.

                                                                        • Re: macOS Sierra Automount on Startup
                                                                          Raka74 Level 1 Level 1 (0 points)

                                                                          I dealt with it completely

                                                                           

                                                                          Restore from Time Capsule backup - back to El Capitan.

                                                                           

                                                                          I want my Mac mini to mount some (media) folders on  my NAS on boot, I have mountwatcher installed and I dont want to use any srcipt to press 'Enter'

                                                                            • Re: macOS Sierra Automount on Startup
                                                                              Atarimac Level 1 Level 1 (10 points)

                                                                              If you use my above solution, you do not need to press enter nor script pressing enter.  Everything just works.  The mount location is moved, but that is seamless to your workflow.

                                                                               

                                                                              Instead of the mount point being in /Volumes it is located in your home folder.

                                                                            • Re: macOS Sierra Automount on Startup
                                                                              iMachine Level 1 Level 1 (0 points)

                                                                              Okay, I think I have a solution to this that will work for me at least.

                                                                              I wasn't interested in mounting the network shares to a user folder instead of inside the default /Volumes folder.

                                                                              I tried adding a symbolic link to the /Volumes folder to a new location where the network shares would be mounted but that symbolic link is deleted on reboot.

                                                                              But then I thought after reading some of the advice here: What if I have a volume on the local drive called "Network_Shares" or "Network_Storage" that I mount all the shares inside? This "Network_Storage" volume would then live inside the /Volumes folder and the shares would live inside it....keeps it nice and clean and easy to access.

                                                                              Here's what I did to work around this issue:

                                                                              Opened up disk utility and added a small partition (100MB) but it can be much smaller.

                                                                              This partition will only serve as the root level for mounting network volumes is is automatically mounted every time the mac boots up.

                                                                              Then I altered my applescript I originally posted near the top of this thread to read as follows:

                                                                              --

                                                                              --

                                                                              --

                                                                              --

                                                                              --

                                                                              --this first part is for my macbook only so it doesn't attempt to mount the shares unless I'm at the location where the wifi SSID is broadcast

                                                                                set theWifi to "MySSID" -- the wifi SSID

                                                                                set theList to paragraphs of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk '{print $1}'") -- get the wifi list

                                                                                if theList contains theWifi then

                                                                                set serverAddress1 to "UserName:Password@Server-Address/Share_Name1"

                                                                                set serverVolume1 to "Share_Name1"

                                                                                set mountPoint1 to "/Volumes/Network_Storage/Share_Name1"

                                                                              -- the line above might also be changed to set mountPoint1 to "Volumes/Network_Storage/" & serverVolume1

                                                                                tell application "Finder"

                                                                                try

                                                                                if disk serverVolume1 exists then -- do attempt anything since it's presumable already mounted

                                                                                else

                                                                                with timeout of 3 seconds

                                                                                do shell script "[ ! -d " & mountPoint1 & " ] && mkdir -p " & mountPoint1 & " || echo directoryOK" -- create the folder to host the mount point if it doesn't already exist

                                                                                do shell script "mount -t smbfs //" & serverAddress1 & " " & mountPoint1

                                                                                end timeout

                                                                                end if

                                                                                end try

                                                                                end tell

                                                                                set serverAddress2 to "UserName:Password@Server-Address/Share_Name2"

                                                                                set serverVolume2 to "Share_Name2"

                                                                                set mountPoint2 to "/Volumes/Network_Storage/Share_Name2"

                                                                                tell application "Finder"

                                                                                try

                                                                                if disk serverVolume2 exists then -- do attempt anything since it's presumable already mounted

                                                                                else

                                                                                with timeout of 3 seconds

                                                                                do shell script "[ ! -d " & mountPoint2 & " ] && mkdir -p " & mountPoint2 & " || echo directoryOK"

                                                                                do shell script "mount -t smbfs //" & serverAddress2 & " " & mountPoint2

                                                                                end timeout

                                                                                end if

                                                                                end try

                                                                                end tell

                                                                              end if

                                                                              display alert "**** on this Apple!"

                                                                              delay 10 -- check for drops every 10 seconds, may not need this anymore as it was added back in Mavericks, it's an enless loop so if you unmount a volume it will mount back within 10 seconds

                                                                              end repeat

                                                                                • Re: macOS Sierra Automount on Startup
                                                                                  DDu-Alvin Level 1 Level 1 (0 points)

                                                                                  Hi,

                                                                                   

                                                                                  I tyied 2 mthods

                                                                                   

                                                                                  1. Mount the net disk under /Users/user/mountpoint

                                                                                  2. Create a new partition and mount net disk under /Volumes/newpartion/mountpoint

                                                                                   

                                                                                  Both methods could mount the net disk properly, but I still face some access issues.

                                                                                   

                                                                                  When I was trying to copy a movie from mounted net disk, it shows "I cannot copy the file, you do not have the read access"

                                                                                   

                                                                                  Anyone got the same problem?

                                                                                   

                                                                                  Thanks

                                                                                   

                                                                                  ===============================

                                                                                  Sorry about that, got the problem, something wrong with my net disk NTFS Security Settings~

                                                                                   

                                                                                  I reset the disk security access, took the ownership access with current user.

                                                                                    • Re: macOS Sierra Automount on Startup
                                                                                      tod1212 Level 1 Level 1 (0 points)

                                                                                      The problem is fixed for me. Automount works again.

                                                                                      Here is what I did:

                                                                                      - deleted the old shared volume item in user startup items.

                                                                                      - deleted any entrys regarding the NAS (Synology) in the keychain.

                                                                                       

                                                                                      PLUS:

                                                                                       

                                                                                      - installed the latest cricial update for my Synology NAS (6.0.2 update 2)

                                                                                       

                                                                                      Then:

                                                                                      restart Mac, connect to shared volume in finder with cmd+k, drag connected share into user startup items.

                                                                                      -> automount works again.

                                                                                    • Re: macOS Sierra Automount on Startup
                                                                                      tpas Level 1 Level 1 (0 points)

                                                                                      Thanks man! I used your script and altered it a little. Now I finally have a working automount on my NAS shares!

                                                                                       

                                                                                      I changed your script, because of a few reasons:

                                                                                      1. It goes on eternally and on shutdown of my Mac, it prevents the shutdown (I created an app out of the script). I only want to run it on boot, so no eternal run necessary. So I added a maximum number of tries (in my case set to 5)

                                                                                      2. It doesn't mount when I plug in my ethernet cable with a shutdown wifi. I want it to mount also over the ethernet, so I added this check

                                                                                      3. I cleaned it up a little, using a little more variables and a function call

                                                                                       

                                                                                      Here's my script:

                                                                                       

                                                                                      set NrMounted to 0

                                                                                      set MaxMount to 4 -- max number of networkshares to mount

                                                                                      set NrTries to 0

                                                                                      set MaxTries to 5 -- max tries before quit

                                                                                      repeat while NrMounted is not MaxMount and NrTries is not MaxTries

                                                                                        set theWifi to "********** Fill in your Wifi SSID here *******************" -- the wifi SSID

                                                                                        set theList to paragraphs of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk '{print $1}'") -- get the wifi list

                                                                                        set EthernetStatus to do shell script "ifconfig en0 | grep 'status' | cut -d ':' -f 2 | tr -d ' '" -- get ethernet status

                                                                                        if theList contains theWifi or EthernetStatus = "active" then

                                                                                       

                                                                                        if MountedSuccessfull("****** fill in the name of your first share here *************") then set NrMounted to NrMounted + 1

                                                                                        if MountedSuccessfull("****** fill in the name of your second share here *************") then set NrMounted to NrMounted + 1

                                                                                        if MountedSuccessfull("****** fill in the name of your third share here *************") then set NrMounted to NrMounted + 1

                                                                                        if MountedSuccessfull("****** fill in the name of your fourth share here *************") then set NrMounted to NrMounted + 1

                                                                                       

                                                                                        end if

                                                                                        set NrTries to NrTries + 1

                                                                                        delay 10 -- waiting time before next try

                                                                                      end repeat


                                                                                      on MountedSuccessfull(VolumeName)

                                                                                        set NASUserCredentials to "****************** fill in your usercredentials on your NAS shares here. In the form: user:password ******************"

                                                                                        set NASIP to "***************** fill in the IP of your NAS here. for example: 19.168.1.112"

                                                                                        set MountPointFolder to "******************** fill in the place where to mount on your Mac here. for example: /Users/yourname/NAS/  (don't forget the last '/') ****** "

                                                                                       

                                                                                        set Mounted to false

                                                                                        set serverAddress to NASUserCredentials & "@" & NASIP & "/" & VolumeName

                                                                                        set mountPoint to MountPointFolder & VolumeName

                                                                                        tell application "Finder"

                                                                                        try

                                                                                        if disk VolumeName exists then -- it's presumable already mounted

                                                                                        else

                                                                                        with timeout of 3 seconds -- try to mount

                                                                                        do shell script "[ ! -d " & mountPoint & " ] && mkdir -p " & mountPoint & " || echo directoryOK" -- create the folder to host the mount point if it doesn't already exist

                                                                                        do shell script "mount -t smbfs /

                                                                                        set Mounted to true

                                                                                        end timeout

                                                                                        end if

                                                                                        end try

                                                                                        end tell

                                                                                        return Mounted

                                                                                      end MountedSuccessfull

                                                                                        • Re: macOS Sierra Automount on Startup
                                                                                          vancityguy Level 1 Level 1 (0 points)

                                                                                          Are you able to help me? I want the exact same functionality you do so I decided to use your script, but every time I try to go and save it as an application using AppleScript, I get a Syntax error Expected "end" but found unknown token.

                                                                                           

                                                                                          I'm not a programmer, so am not able to self debug.

                                                                                           

                                                                                           

                                                                                          All I've been able to do so far is Launch Apple Script Editor and pasted the script following =========== below and tried to hit save. Can you help me understand what I'm doing wrong please?

                                                                                           

                                                                                           

                                                                                          ===========

                                                                                           

                                                                                          set NrMounted to 0

                                                                                          set MaxMount to 2 -- max number of networkshares to mount

                                                                                          set NrTries to 0

                                                                                          set MaxTries to 5 -- max tries before quit

                                                                                          repeat while NrMounted is not MaxMount and NrTries is not MaxTries

                                                                                            set theWifi to "VancityGuyWifi" -- the wifi SSID

                                                                                            set theList to paragraphs of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk '{print $1}'") -- get the wifi list

                                                                                            set EthernetStatus to do shell script "ifconfig en0 | grep 'status' | cut -d ':' -f 2 | tr -d ' '" -- get ethernet status

                                                                                            if theList contains theWifi or EthernetStatus = "active" then

                                                                                           

                                                                                            if MountedSuccessfull("Volume_1") then set NrMounted to NrMounted + 1

                                                                                            if MountedSuccessfull("Volume_2") then set NrMounted to NrMounted + 1

                                                                                           

                                                                                           

                                                                                            end if

                                                                                            set NrTries to NrTries + 1

                                                                                            delay 10 -- waiting time before next try

                                                                                          end repeat

                                                                                          on MountedSuccessfull(VolumeName)

                                                                                            set NASUserCredentials to "username:password"

                                                                                            set NASIP to "100.100.100.2"

                                                                                            set MountPointFolder to "/Users/Vancityguy/NAS/"

                                                                                           

                                                                                            set Mounted to false

                                                                                            set serverAddress to NASUserCredentials & "@" & NASIP & "/" & VolumeName

                                                                                            set mountPoint to MountPointFolder & VolumeName

                                                                                            tell application "Finder"

                                                                                            try

                                                                                            if disk VolumeName exists then -- it's presumable already mounted

                                                                                            else

                                                                                            with timeout of 3 seconds -- try to mount

                                                                                            do shell script "[ ! -d " & mountPoint & " ] && mkdir -p " & mountPoint & " || echo directoryOK" -- create the folder to host the mount point if it doesn't already exist

                                                                                            do shell script "mount -t smbfs /

                                                                                            set Mounted to true

                                                                                            end timeout

                                                                                            end if

                                                                                            end try

                                                                                            end tell

                                                                                            return Mounted

                                                                                          end MountedSuccessfull

                                                                                      • Re: macOS Sierra Automount on Startup
                                                                                        andrewha Level 1 Level 1 (0 points)

                                                                                        Try this for auto mounting your SMB / AFP / NFS volumes: https://itunes.apple.com/us/app/automounter/id1160435653?ls=1&mt=12

                                                                                         

                                                                                        I ran into the same problem, so I developed around it.

                                                                                          • Re: macOS Sierra Automount on Startup
                                                                                            KillerBob Level 1 Level 1 (0 points)

                                                                                            Andrew,

                                                                                             

                                                                                            I bought your Automounter app, but must admit I am a bit dissapointed... I can't use the NAS name as defined in the settings on the NAS???

                                                                                             

                                                                                            My NAS is named "BMK-rnp", and that name works in Apple scripts, and in Finder the NAS shows up as "BMK-rnp (AFP)". However, I can't use it in your Automounter app, and only if I use the IP address does it work. I do not want to use the IP address, because then I have to rescan all my apps that have links to files on the NAS. Hence it is not feasible for me.

                                                                                            • Re: macOS Sierra Automount on Startup
                                                                                              3mk4i Level 1 Level 1 (0 points)

                                                                                              @andrewha I created a developer forum account just to say thank you! I bookmarked the Automount post you presumably did on Lime Tech & I've been using the scripts & instructions for a few years now on various macs. Discovered this post when looking into having to fix the issue (I check the Lime Tech post a few days ago but it's old so didn't expect an update). Downloaded your app, it works great... Then went back to the Lime Tech (to find the lcoations to remove the launch files) & saw your update! So, thanks for the scripts & especially the new app!

                                                                                               

                                                                                              To all others, I'd advise getting this app, it's definitely the best way of creating these mounts...

                                                                                            • Re: macOS Sierra Automount on Startup
                                                                                              cokyq Level 1 Level 1 (0 points)

                                                                                              I also have a similar problem.  In El Capitan, the following applecript mounted my Synology disktation NAS volumes.  Now in Sierra, it fails to find my diskstation drives (does not exist or is not available) and then gives an error -5016.

                                                                                               

                                                                                              tell application "Finder"

                                                                                                mount volume "smb://DiskStation/Volume1/Video" as user name "Ralph Quinones"

                                                                                                mount volume "smb://Diskstation/Volume1/Music" as user name "Ralph Quinones"

                                                                                                mount volume "smb://Diskstation/Volume1/Photos" as user name "Ralph Quinones"

                                                                                                mount volume "smb://Diskstation/Volume1/Downloads" as user name "Ralph Quinones"

                                                                                                mount volume "smb://Diskstation/Volume1/Documents" as user name "Ralph Quinones"

                                                                                              end tell


                                                                                              I am not a programmer and was able to build this a few years ago by googling it.  Now I am trying to find help on how to rewrite the script so it works and mount my NAS drives whenever my MAC boots.  If I try to do this in user/login in preferences, only 2 drives mount.  Never been able to make all 5 mount from user login preferences.

                                                                                               

                                                                                              Any ideas how to rewrite the mount volume so it works?  I remarked my original mount volume statements, and used the following line:

                                                                                               

                                                                                              mount volume "afp://192.168.1.41"

                                                                                               

                                                                                              This does not crash the apple script. It prompts me to enter my password, then I can select the drives I want to mount, and it it works.  Does anyone know how to automate loading all 5 drives without having to authenticate and select the volumes?

                                                                                               

                                                                                              Thanks in advance for your help.

                                                                                              • Re: macOS Sierra Automount on Startup
                                                                                                Alfa-Male Level 1 Level 1 (0 points)

                                                                                                So this is quite interesting, not only because lots of people are having the same issue as I found, but also that there are so many ways to mount a network share in macOS!  Amazes me that people have been complaining about how awkward it is compared to Windows yet we still don't have a simple method to do this.

                                                                                                 

                                                                                                Anyway, I digress;  I have a simple shell script that also stopped working with Sierra and I found the same workaround of mounting to my home folder to work, however I'm finding that after waking the mac from standby all the network drive icons have changed to the standard HDD icon and all of them are named "Macintosh HD".  They're completely empty if I open any of then and they cannot be ejected.  If I re-run the script then the spurious drives disappear and the normal network drives re-appear.  Definitely didn't have this on any OS until Sierra.

                                                                                                 

                                                                                                Anyone else had this?  Script below for reference, it's not pretty but it works!

                                                                                                 

                                                                                                #! /bin/sh
                                                                                                if [ ! -d ~/Mounts/itunes ]
                                                                                                then
                                                                                                  mkdir ~/Mounts/itunes
                                                                                                fi
                                                                                                
                                                                                                
                                                                                                if [ ! -d ~/Mounts/Software ]
                                                                                                then
                                                                                                  mkdir ~/Mounts/Software
                                                                                                fi
                                                                                                
                                                                                                
                                                                                                if [ ! -d ~/Mounts/Photos ]
                                                                                                then
                                                                                                  mkdir ~/Mounts/Photos
                                                                                                fi
                                                                                                
                                                                                                
                                                                                                if [ ! -d ~/Mounts/Movies ]
                                                                                                then
                                                                                                  mkdir ~/Mounts/Movies
                                                                                                fi
                                                                                                
                                                                                                
                                                                                                if [ ! -d ~/Mounts/Household ]
                                                                                                then
                                                                                                        mkdir ~/Mounts/Household
                                                                                                fi
                                                                                                
                                                                                                
                                                                                                if [ ! -d ~/Mounts/NAS_Home ]
                                                                                                then
                                                                                                        mkdir ~/Mounts/NAS_Home
                                                                                                fi
                                                                                                
                                                                                                
                                                                                                if [ ! -d ~/Mounts/Dropbox ]
                                                                                                then
                                                                                                        mkdir ~/Mounts/Dropbox
                                                                                                fi
                                                                                                if [ ! -d ~/Mounts/Lightroom ]
                                                                                                then
                                                                                                        mkdir ~/Mounts/Lightroom
                                                                                                fi
                                                                                                mount_afp afp://username:password@10.0.0.3/Music ~/Mounts/itunes
                                                                                                mount_afp afp://username:password@10.0.0.3/Public/Software ~/Mounts/Software
                                                                                                mount_afp afp://username:password@10.0.0.3/Photos ~/Mounts/Photos
                                                                                                mount_afp afp://username:password@10.0.0.3/Videos ~/Mounts/Movies
                                                                                                mount_afp afp://username:password@10.0.0.3/Public/Household ~/Mounts/Household
                                                                                                mount_afp afp://username:password@10.0.0.3/homes/username ~/Mounts/NAS_Home
                                                                                                mount_afp afp://username:password@10.0.0.3/homes/admin/Dropbox ~/Mounts/Dropbox
                                                                                                
                                                                                                
                                                                                                osascript -e 'tell application "Terminal" to if not ((count windows) > 1) then quit'
                                                                                                
                                                                                                
                                                                                                • Re: macOS Sierra Automount on Startup
                                                                                                  Julieanne Level 1 Level 1 (0 points)

                                                                                                  Hi

                                                                                                   

                                                                                                  I'm new to apple, but have a rudmentary programming background, and I'm trying to get the script to work with no joy ..

                                                                                                  I have created the following script but nothing happens when I run it - other than the running icon for 50 seconds?

                                                                                                  Is there anything else I need to set in the apple environment for it to run - I have a Macbook air 2014

                                                                                                  Presumably it should create, and I should see,  mount points in the named directory

                                                                                                   

                                                                                                  set NrMounted to 0

                                                                                                  set MaxMount to 4 -- max number of networkshares to mount

                                                                                                  set NrTries to 0

                                                                                                  set MaxTries to 5 -- max tries before quit

                                                                                                  repeat while NrMounted is not MaxMount and NrTries is not MaxTries

                                                                                                    set theWifi to "T******" -- the wifi SSID

                                                                                                    set theList to paragraphs of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk '{print $1}'") -- get the wifi list

                                                                                                    set EthernetStatus to do shell script "ifconfig en0 | grep 'status' | cut -d ':' -f 2 | tr -d ' '" -- get ethernet status

                                                                                                    if theList contains theWifi or EthernetStatus = "active" then

                                                                                                   

                                                                                                    if MountedSuccessfull("Music") then set NrMounted to NrMounted + 1

                                                                                                    if MountedSuccessfull("TV Series") then set NrMounted to NrMounted + 1

                                                                                                    if MountedSuccessfull("New") then set NrMounted to NrMounted + 1

                                                                                                    if MountedSuccessfull("Videos") then set NrMounted to NrMounted + 1

                                                                                                   

                                                                                                    end if

                                                                                                    set NrTries to NrTries + 1

                                                                                                    delay 10 -- waiting time before next try

                                                                                                  end repeat

                                                                                                  on MountedSuccessfull(VolumeName)

                                                                                                    set NASUserCredentials to "Media:password"

                                                                                                    set NASIP to "Office-PC"

                                                                                                    set MountPointFolder to "/Users/julieanne/Media/" -- I have created this directory in Finder

                                                                                                    set Mounted to false

                                                                                                    set serverAddress to NASUserCredentials & "@" & NASIP & "/" & VolumeName

                                                                                                    set mountPoint to MountPointFolder & VolumeName

                                                                                                    tell application "Finder"

                                                                                                    try

                                                                                                    if disk VolumeName exists then -- it's presumably already mounted

                                                                                                    else

                                                                                                    with timeout of 3 seconds -- try to mount

                                                                                                    do shell script "[! -d " & mountPoint & "] && mkdir -p " & mountPoint & " || echo directoryOK" -- create the folder to host the mount point if it doesn't already exist

                                                                                                    do shell script "mount -t smbfs //" & serverAddress & " " & mountPoint  set Mounted to true

                                                                                                    end timeout

                                                                                                    end if

                                                                                                    end try

                                                                                                    end tell

                                                                                                    return Mounted

                                                                                                  end MountedSuccessfull

                                                                                                  • Re: macOS Sierra Automount on Startup
                                                                                                    hubionmac Level 1 Level 1 (0 points)

                                                                                                    I played around with that and it is just a setting issue inside the keychain. For a saved login you set the privilidges for direct access per program. So if you just add the Finder  to the list of programs that may access the specific keychain entry without asking you it should work.

                                                                                                    Same for Applescript, when you want to mount a share via Script. You just add the Finder (/System/Library/CoreServices/Finder.app) to the trusted apps for a login and in your AppleScript you just make sure that the mount-command is wrapped in an tell app "Finder"-statement

                                                                                                     

                                                                                                    Maybe that screenshot explains better what I mean ;-)

                                                                                                     

                                                                                                    https://www.apfeltalk.de/community/attachments/bildschirmfoto-2016-10-27-um-00-00-23-png.138953/

                                                                                                    • Re: macOS Sierra Automount on Startup
                                                                                                      danielstonehouse Level 1 Level 1 (0 points)

                                                                                                      I've solved this in a kludgy way - with an applescript that ensures the login window has focus, and sends an enter keypress to the login window.

                                                                                                       

                                                                                                      Save applescript as an application and at to your login items in Users and Groups under System preferences. Adjust the delay to suit

                                                                                                       

                                                                                                      delay 5

                                                                                                      tell application "System Events" to tell process "NetAuthAgent" to perform action "AXRaise" of window 1

                                                                                                      tell application "System Events" to key code 36

                                                                                                       

                                                                                                       

                                                                                                      You will need to add the application containing the script to the accessability list under System Preferences / Security and Privacy to grant it access to control your computer

                                                                                                      • Re: macOS Sierra Automount on Startup
                                                                                                        aktivomat Level 1 Level 1 (0 points)

                                                                                                        I found a very simple solution for this problem by chance. I just put the server icon (keychain must be saved before) to my dock menu (on the right side). So all servers attached to the dock (keychains saved) will automount without any password confirmation.

                                                                                                          • Re: macOS Sierra Automount on Startup
                                                                                                            michaelfinleysummers Level 1 Level 1 (0 points)

                                                                                                            Wow!  This worked -- and so easy!

                                                                                                            • Re: macOS Sierra Automount on Startup
                                                                                                              VAMark Level 1 Level 1 (0 points)

                                                                                                              How do you add the server icon to the dock menu (what are the steps to do this)…maybe I'm making this more complicated that it is?

                                                                                                                • Re: macOS Sierra Automount on Startup
                                                                                                                  JoseCRamirez Level 1 Level 1 (0 points)

                                                                                                                  Open a Finder window, click on a network share (icons on the left).

                                                                                                                  Right-click on the Finder window title (over the name of the network share) and click below it on 'Network' (this is the parent folder, containing all network servers).

                                                                                                                  Now you have the server icon, which you can drag to your dock.

                                                                                                                  At least for me, this trick does not avoid the system asking for credentials for the first time! But it speeds up greatly the server discovery & connection to shares. Thanks!

                                                                                                                  • Re: macOS Sierra Automount on Startup
                                                                                                                    RealDealNeil Level 1 Level 1 (0 points)

                                                                                                                    You need to drag the folder for the network share into the dock, not the network server.

                                                                                                                     

                                                                                                                    For example:

                                                                                                                    1) Connect to your network share (i.e. smb://192.168.1.50/Media)

                                                                                                                    - Open Finder

                                                                                                                    - In the menu bar, Go -> Connect to Server

                                                                                                                    - Type server address and hit Connect

                                                                                                                    - Provide credentials if prompted (check to remember credentials in keychain)

                                                                                                                    - Choose share from list to access

                                                                                                                    2) Open the network server from Finder (on left side under "Shared"). The list of shares for this network will appear on right.

                                                                                                                    3) Drag the folder for the share you want to the dock on the right side (i.e. next to the Trash)

                                                                                                                     

                                                                                                                    You should be automatically mounted and connected to the share upon restart. This works like a charm for me.  Simple solution!

                                                                                                                  • Re: macOS Sierra Automount on Startup
                                                                                                                    renglm_ Level 1 Level 1 (0 points)

                                                                                                                    YES – helped instantly on two devices (10.12.1), same NAS (Synology, fully updated)

                                                                                                                    Volume appeared at reboot like magic – now it's normality, again…

                                                                                                                    Wasted time (until reading here, developer account etc) more than eight hours.

                                                                                                                     

                                                                                                                    Thank you, Apple

                                                                                                                  • Re: macOS Sierra Automount on Startup
                                                                                                                    hwoltering Level 1 Level 1 (0 points)

                                                                                                                    But to anyone experiencing this issue, I do not really mind the password question, however the first drive I try to mount via the script gets duplicated under "volumes".

                                                                                                                     

                                                                                                                    My script:

                                                                                                                    tell application "Finder"
                                                                                                                      try
                                                                                                                      mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Documents"
                                                                                                                      mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Music"
                                                                                                                      mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Video"
                                                                                                                      mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Photography"
                                                                                                                      end try
                                                                                                                    end tell
                                                                                                                    
                                                                                                                    

                                                                                                                     

                                                                                                                    Now when it runs, it immediately creates a "documents" folder in /Volumes/

                                                                                                                    Then it asks my password and then connects the drives. However, because "Documents" is already there, it creates the 'real' drive on "Documents-1". When I then disconnect the drives and connect them again via the script, they create a "documents-1" and "documents-2". This changes the path of the drive which gives me problems with applications that do not know the updated path.

                                                                                                                     

                                                                                                                    The weird thing is that when I do connect manually via finder this does not happen although it still asks for the password.

                                                                                                                     

                                                                                                                    Any ideas how to solve that?

                                                                                                                    • Re: macOS Sierra Automount on Startup
                                                                                                                      hendryman Level 1 Level 1 (0 points)

                                                                                                                      i tweaked my applescript to klick the dialog box button by spawning a second applescript via shell right before my first (main) script issues the mount command - like this:

                                                                                                                       

                                                                                                                        do shell script "

                                                                                                                      osascript -e 'delay 2 -- initial wait period until the server login/password box appears

                                                                                                                      tell application \"NetAuthAgent\" to activate

                                                                                                                      tell application \"System Events\" to keystroke return

                                                                                                                      delay 1 -- secondary wait period until the volumee chooser box appears

                                                                                                                      tell application \"NetAuthAgent\" to activate

                                                                                                                      tell application \"System Events\" to keystroke return' > /dev/null 2>&1 &"

                                                                                                                       

                                                                                                                      very important: the "> /dev/null 2>&1 &" allows the "main" applescript to continue before the shell applescript ends, thus allowing two scripts to run in parallel

                                                                                                                      • Re: macOS Sierra Automount on Startup
                                                                                                                        vbelloli Level 1 Level 1 (0 points)

                                                                                                                        Problem finally solved by Apple with OSX 10.12.2

                                                                                                                        • Re: macOS Sierra Automount on Startup
                                                                                                                          3D Touch Level 1 Level 1 (0 points)

                                                                                                                          3D Touch

                                                                                                                          • Re: macOS Sierra Automount on Startup
                                                                                                                            gniemetz Level 1 Level 1 (0 points)

                                                                                                                            Hi!

                                                                                                                             

                                                                                                                            I have made a shell script which parses a .plist file and mounts the listed shares. All the needed passwords for these shares are NOT stored in the script but retrieved from the local keychain.

                                                                                                                            Have a look at https://github.com/gniemetz/automount/blob/master/automount.sh

                                                                                                                             

                                                                                                                            Hope this helps!

                                                                                                                             

                                                                                                                            best regards

                                                                                                                            Gerd

                                                                                                                            • Re: macOS Sierra Automount on Startup
                                                                                                                              gmon750 Level 1 Level 1 (0 points)

                                                                                                                              I'm monitoring thes thread closely.  It's a real shame that Apple is not making this a priority.  Apple is having a huge presence in the enterprise now, yet can't get basic, simple NAS functionality going.  It's an embarassment actually.

                                                                                                                                • Re: macOS Sierra Automount on Startup
                                                                                                                                  john daniel Level 3 Level 3 (220 points)

                                                                                                                                  I finally upgraded my work machine to Sierra a few weeks ago. I was a bit concerned because of threads like this one. But I can confirm that a true automount via autofs still works fine in Sierra. I'm not using a NAS through. I have an Active Directory environment with a Linux SMB server. Do any of these NAS devices support login authentication via Active Directory or Open Directory? Once I'm logged into the network, I can mount SMB shares with no trouble via entries in /etc/auto_master and similar. Clearly, this is the environment that Apple supports. I've never had a NAS so I don't know if they can be configured to provide a real directory service with authentication.

                                                                                                                                • Re: macOS Sierra Automount on Startup
                                                                                                                                  themacmeister Level 1 Level 1 (0 points)

                                                                                                                                  I can confirm this is working with mount_smbfs as well... (except without -t)

                                                                                                                                   

                                                                                                                                   

                                                                                                                                  • Re: macOS Sierra Automount on Startup
                                                                                                                                    jeanfrancoish Level 1 Level 1 (0 points)

                                                                                                                                    Hi,
                                                                                                                                    I am trying this, that is very simple and seems working

                                                                                                                                     

                                                                                                                                    http://blog.grapii.com/2015/06/keep-network-drives-mounted-on-mac-os-x-using-autofs/