Working Windows-based solution

I've got a folder on a network share which works great in Windows. It is basically an index of other available file servers. It looks something like this:

    Server2.lnk   <-(links to \\server2\files)
    Server3.lnk   <-(links to \\server3\files)
    Server4.lnk   <-(links to \\server4\files)

I'm trying to replicate this functionality in macOS, but I have run into these problems:

Attempting to use an Alias in macOS

I connected to //server2/files via Finder using Go -> Connect to Server. Once I was connected in Finder, I created an Alias using for the //server2/files folder. I then copied that Alias to the //server1/directory location. The Alias works... as long as I'm using the same computer from which I created the Alias. But if I try to use it from another mac, it fails.

The other mac doesn't even seem to recognize the file as an Alias file. It has an icon similar to a terminal icon, and when I double-click it, the mac tells me that there is no Application defined to open the file. I noticed that the original created Alias file doesn't seem to have any kind of extension, so I'm not sure how a different mac is supposed to recognize it as an Alias file.

The nice thing about a Windows .lnk file is that it seems to work reliably and consistently no matter from what machine the .lnk is accessed, whereas a mac Alias file seems to somehow depend on some configuration of the original machine where it was created.

For example, if I open the Alias file in vi, I can see amongst the garbled code that it includes at least the username used to access the Share, whereas I want each user that clicks on the Alias to access the Share using their own credentials (the mac is joined to AD and users login using their AD credentials). Again, this works seamlessly with UNC paths and .lnk files.

Attempting to use a terminal script in macOS

I tried to make a simple script that mounts the shares. So inside //server1/directory I created a file Server2.command with the following content:

mkdir /Volumes/Server2
mount_smbfs //server2/files /Volumes/Server2
cd /Volumes/Server2
open .

My problem with this solution is that I have many servers and many users using the same machine. One great thing about using the Connect to Server option in Finder is that it seems to automatically "clean up" the /Volumes directory. After ejecting a share, or after ending a session, it removes the corresponding /Volumes/Sharename folder. I don't see any way to accomplish the same behavior if I use this terminal-based solution.


Can someone give me a good way to replicate the .lnk functionality I have described above?

I know the Windows links functions via UNC paths, whereas in macOS I can only access these network shares via smb or afp mounts, but since I see that the Connect to Server option pretty much functions how I need it to, I just need a way to use that same functionality, with the caveat that I need to automate it, because I'm not going to ask my Users (I have many Users using the same machine) to each create a Connect to Server Alias manually.

| improve this question | | | | |
  • Yes, as you've discovered, aliases are pretty closely tied to the computer that created them. The way around this would normally be symbolic links, although I'm not sure how well that would work in the arrangement you want. – tubedogg Nov 6 '16 at 4:22
  • I don't think I can create a symbolic link to an smb or afp share. I could only create a symbolic link to a mount point on the computer, which doesn't really solve my problem. I basically need a "mount-on-demand" solution that also includes an "unmount-on-demand" function. All the functionality I need is already contained within Finder's Connect to Server. I basically need a way to call that functionality from the command line, or replicate it in another way. – Daniel Nov 6 '16 at 16:42

Found the answer. You must create an .afploc file. This is similar to an .inetloc file.

The easiest way to create a .afploc file:

  1. open Finder
  2. Go -> Connect to Server
  3. type the address in the Connect to Server window (e.g. afp://server.domain.com/
  4. highlight what you just typed (afp://server.domain.com)
  5. grab what you just highlighted and drag it to the desktop (or any folder, presumably) and release
  6. a file named server.domain.com.afploc should be created automatically on your desktop
  7. you can then copy that file anywhere and it will function to automatically start the Go -> Connect to Server process on any mac computer
  8. you can also rename the file if you want, and you can edit its contents to create other .afploc files that point to other servers or paths
  9. you can also use this same process and substitute an smb:// path. this creates an .inetloc file which works the same way
| improve this answer | | | | |
  • Thanks for this, unfortunately I run into two problems with it. 1. The resulting inetloc file prompts me to log in every time, and does not store my credentials to the keychain despite the option to do so being checked, and 2. The resulting inetloc file cannot be placed in the sidebar, nor can a symlink to it. Any idea if either of these issues can be worked around? I just want an "alias" to a network volume permanently in my sidebar. Normal symlinks vanish if the share is not mounted. – JVC 2 days ago

To complement Daniel's answer, it may be worth noting that these .afploc or .inetloc files are just plain XML plist files. So you could also generate them by hand or from a script. An example file for an smb share looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

So if you have many such shortcuts to define, you could have a file like this:

$ cat shares.txt 
server1 share1
server2 share2
server3 other-share

And then run this to generate .inetloc files for every server-share:

cat shares.txt | while read server share; do
  cat <<'EOF' >"$server-$share.inetloc"
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
| improve this answer | | | | |

My feeling about what you want to achieve in Mac OS (or a Unix) works with a symbolic link. Finder has functionalities above OS embedded functions. I guess an alias won't work with Terminal / Shell. Symbolic links are created on the shell but also work transparent in Finder. Try out the thread Backup iPhone to external drive on Mac ... this explains symbolic links wonderfully.

Hope, this was what your are looking for!

| improve this answer | | | | |
  • 1
    I know how a symbolic link works, but unless I'm mistaken a symbolic link only works to point to a path on the local filesystem. To use a symbolic link I would have to mount the network share to a local mountpoint first, which really just brings me right back to the same problem I have with my terminal-based solution. – Daniel Nov 8 '16 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .