Unmount disk image at logout

Account Preferences->Login items allows you to list disk images to mount on login, but these disk images do not get unmounted at logout - they can still be seen by other accounts.

Is there any way to force the Login items disk images to be unmounted when an account logs out?

MacBook Pro, Mac OS X (10.6.1)

Posted on Oct 27, 2009 1:04 PM

Reply
5 replies

Oct 27, 2009 1:12 PM in response to Phill Hughes

How comfortable are you with the Terminal and scripting?

Could always just create a small AppleScript that would resemble this:

do shell script "umount /Volumes/Location of the mount"


...and save it as an app. Then you can have the users double click on this at the end before logging out... May have to be set as a cron job - test login status and time out, etc.

Oct 28, 2009 8:59 AM in response to Phill Hughes

Phill Hughes wrote:
Fine with scripting, but if the users have to remember to click something before logging out then they just as well eject the disk images. A cron job would work, but it would be nice to just have it happen. Thanks for the suggestions.

cron won't be good for this unless you want to run it every minute. I would use a logout hook

http://support.apple.com/kb/HT2420?viewlocale=en_US
so it's only executed on the logout. it can run an apple script along the following lines

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
tell application "Finder"
set nmd to number of disks
--this ejects externals and disk images
if nmd > 1 then

repeat with i from 2 to nmd


eject disk (nmd - i + 2)

end repeat

end if





end tell</pre>

this will unmount all externals and disk images when a user logs out.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Unmount disk image at logout

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.