How to prevent a network share from opening when mounted

kmitnick
New Contributor III
New Contributor III

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 12

nessts
Valued Contributor II

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

nessts
Valued Contributor II

if you cannot tell the nobrowse option is the key

bentoms
Release Candidate Programs Tester

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
New Contributor III
New Contributor III

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
New Contributor III
New Contributor III

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
Release Candidate Programs Tester

@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
New Contributor III
New Contributor III

@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
Legendary Contributor III

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
New Contributor III
New Contributor III

@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

panacea
New Contributor

What was the solution to this?

bentoms
Release Candidate Programs Tester

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

jrclayton
New Contributor

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?