Skip to main content
Question

How to prevent a network share from opening when mounted

  • September 26, 2014
  • 12 replies
  • 31 views

kmitnick
Forum|alt.badge.img+12

I’m hoping someone has a solution for this. I have a few network shares (AFP / SMB) that mount when a user logs in. When the share mounts, it automatically opens up. I don’t want that to happen. I just want the share to mount without it opening.

Does anyone know how to solve this issue without the use of an additional script?

Is there a defaults write command that can be issued to a certain plist?

Any help would be greatly appreciated.

Thanks

Keith

12 replies

Forum|alt.badge.img+18
  • Valued Contributor
  • September 26, 2014

mkdir /tmp/cs
mount_smbfs -o nobrowse //domain;user:password@SERVER/CasperShare /tmp/cs


Forum|alt.badge.img+18
  • Valued Contributor
  • September 26, 2014

if you cannot tell the nobrowse option is the key


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • September 26, 2014

The below doesn't open the shares, but adds them to the desktop.

http://macmule.com/2011/09/08/how-to-map-drives-printers-based-on-ad-group-membership-on-osx/

I'm guessing you're adding the shares as "Open at login"?


kmitnick
Forum|alt.badge.img+12
  • Author
  • Contributor
  • September 26, 2014

nessts,

I appreciate your prompt reply. The command you sent does work but it actually hides it from the desktop. I still want to be able to see the share on the desktop, I just don't want it to automatically open when it's mounted.

Keith


kmitnick
Forum|alt.badge.img+12
  • Author
  • Contributor
  • September 26, 2014

bentoms,

Thanks for you response. I'm looking for a way to accomplish this without additional scripts. My gut tells me theres a plist somewhere that is responsible for opening a share when it's mounted on the desktop.

Keith


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • September 26, 2014

@kmitnick How are you getting the shares to mount at login? I think it maybe the method that is making them open, as its not common.


kmitnick
Forum|alt.badge.img+12
  • Author
  • Contributor
  • September 26, 2014

@bentoms,

It happens regardless of how it's mounted. for example, Go>Connect to Server> or via a login item, or via a profile.

Once the share mounts on the desktop, it opens up. Similar to how a DVD or CD would open on mount back in the day.

Keith


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • September 26, 2014

Then use @nessts command and remove the -o nobrowse. It will mount and be visible in the Finder, but not auto open. There is a -noautoopen flag you can use when mounting disk images from a command line with hdiutil, but mount_smbfs doesn't have a similar flag.

Also, I don't think there is a simple plist to control that behavior, so you may not have a choice but to use a scripted method to stop that from happening.


kmitnick
Forum|alt.badge.img+12
  • Author
  • Contributor
  • September 27, 2014

@mm2270,

Appreciate your comments. What's puzzling me is if I mount and afp share using apple script or automator, it will not automatically open. When I mount the afp share from Go>Connect to Server, it will automatically open the share in the finder.

I'm trying to figure out what Go>Connect To Server doing differently than applescript or automator. The has to be a setting somewhere that tells the finder to open the share when using Go>Connect to Server.

Not a show stopper but I hope to figure this out one day.

Thanks for the assistance.

Keith


Forum|alt.badge.img
  • New Contributor
  • August 15, 2016

What was the solution to this?


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • August 20, 2016

@panacea FWIW, the solution in my post here mounts the shares only & doesn't open a Finder window.


Forum|alt.badge.img
  • New Contributor
  • January 31, 2019

Dear Keith,

Did you ever find a solution to suppress this behavior? I've tried to figure it out myself for a long time. Never seen it discussed anywhere else. I routinely mount several shares with Command-K in the finder with just a couple of keystrokes and then I have to hit Command-W half a dozen times just to clean up the mess. I can't imagine no one else has this problem!

I've even gone through the extensive dotfiles found on github for macos (e.g. https://github.com/mathiasbynens/dotfiles/blob/master/.macos) but have still not been successful.

In particular, there are the following defaults described:

Automatically open a new Finder window when a volume is mounted

defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true/false
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true/false
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true/flase

Yet even after changing all three of these to false, the finder still opens a window when I mount a remote AFP/SMB share. So I gave up. Any luck on your end?