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?

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.

Similar Messages

  • Eject Disk Image at logout with AppleScipt?

    Hello, I would like to know how to use AppleScript to write a script that automatically ejects a disk image whenever the user logs out of their account.
    This script would be the complementary inverse to a login item I have setup wherein a specific disk image is mounted upon login.
    Because the disk image to be unmounted will be the same one every time, a script that simply uses the path to the image to accomplish the task will be fine (as opposed to a script that would scan for and unmount any mounted images found).

    Check this one out.
    I found this on MacScripter. You should check out that site too, as there are a lot of applescripts there.
    -- Adjust these values to your own requirements:
    property initialInterval : 5 * minutes -- The initial time to wait before starting the checks to see if the app has quit.
    property checkInterval : 10 -- The time (in seconds) between checks after that.
    property appName : "My App" -- The name of the app to watch.
    property diskName : "My Disk" -- The name of the disk to eject.
    global justOpened
    on run
              set justOpened to true -- Tells the 'idle' handler that this script applet's just started running.
    end run
    on idle
              if (justOpened) then
      -- Reverse the flag for next time and ask for the next 'idle' to come after the intial wait period.
                        set justOpened to false
                        return initialInterval
              else
      -- Otherwise check if the application is (still) running.
                        tell application "System Events" to set appRunning to (application process appName exists)
                        if (appRunning) then
      -- If it is, request the next 'idle' to come after the specified check interval.
                                  return checkInterval
                        else
      -- Otherwise eject the disk (if it's mounted).
                                  tell application "Finder"
                                            if (disk diskName exists) then eject disk diskName
                                  end tell
      -- Issue the log out command. (There'll be a 1-minute count-down dialog).
                                  tell application "System Events" to log out
      -- Tell this stay-open script application to quit. (It will only do so on the next 'idle'.)
      quit
      -- Request the next 'idle' to come after the shortest possible time.
                                  return 1
                        end if
              end if
    end idle

  • How do I make Automator unmount a disk image everytime I quit Entourage?

    I've found a way to password protest my email, by sticking my entourage data files in an encrypted disk image and then making an alias to link into that password protected disk image. My question is how do I make an Automator workflow that unmounts that disk image automatically when I quit Entourage. There has got to be a way to do this. It should be the most simple script.
    On Entourage Quit: Unmount disk image [x]
    But I can't seem to find out how to get this done.
    Can anyone help?

    Encore does have a fit-to-disc feature, called "automatic transcoding", which chooses the bit rate based upon how much media there is to encode, how much room is currently on the disc, and applying format-legal restrictions (minimum and maximum bit rates allowable by the format).
    So for instance, 30 minutes of video will never fill a disc because the required bit rate to do so would be higher than allowable by the format.

  • Script to unmount or eject disk images

    Is there a way to unmount disk images wiuth an automator or applescript? I have such a script to eject all disks, but this won't unmount disk images. I would like something that unmounts everything, except of course the startup disk etc.

    Andrew Gara wrote:
    That works!
    However, I still have the problem that it will only eject 1 of 2 or 2 of 3 or 3 of 4 etc. I always have to run the script again to eject the remaining disk or image.
    It says: Applescript error Finder got an error. Can't get disk 3 (or whatever is remaining.)
    I really appreciate your help btw.
    this of course makes sense because once a disk is ejected it's not counted among the remaining disks. we should start ejecting from the last disk (see the script below). Also, as i found out, Finder's eject command in apple script doesn't unmount internal drives. At least it didn't for me. I' not sure what the story here is.
    One can circumvent this by calling a shell script command.
    Something along the following lines.
    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
    --this ejects internals except for the start up
    set nmd to number of disks
    if nmd > 1 then
    repeat with i from 2 to nmd
    do shell script "diskutil unmount /Volumes/\"" & (name of disk (nmd - i + 2)) & "\"> /dev/null &"
    end repeat
    end if
    end tell
    I tested it on my computer and it ejects 10 disks and disk images well so I think it should work ok most of the times but there are probably situations when it will fail. I'm not sufficiently motivated to refine it.

  • Backup disk and Disk Images not mounting

    *Intial Disk Utility problem:* Recently my trusty 6 year old PowerBook G4 died from hard-drive failure, with most of my data backed up on external drives. Before migrating data over to my new iMac, I performed "First Aid" in "Disk Utility" on the external backup drive. One of the drives (500GB iomega drive) that backed up my PowerBook and my PC had 5 partitions (4 were FAT32, and 1 was NTFS), somehow got erased in Disk Utility. Even though I was just verifying one of the partitions the whole drive was cleared and renamed: disk2s4 (28kb) and disk2s10 (372.5GB). This didn't take much time, so I knew all the data hadn't been cleared, and checked the Security Options for Erase, and its set to "Don't Erase Data."
    *Disk Warrior attempt:* At this point, having a sorta wrecked backup drive that still apparently had data, I bought Disk Warrior and gave that a try. It read the drive the first time, but couldn't recover any of the directory information. Hoping to not overwrite anything, at that point, I didn't proceed with the "rebuild" option. Now when I try Disk Warrior, it just says:
    Directory Cannot be rebuilt due to disk hardware failure (-50,447)
    - This disk appears to be a MacOS standard sik
    - This disk does not appear on the desktop
    - This disk is 372.49 GB in size
    - Disk ID: disk2s10
    - File system: HFS (standard) +even though most of the drives had been fat32+
    Now Disk Warrior doesn't even give the option to scan the drive.
    *Disk Imaging attempt:* Disk Warrior is claiming a hardware problem (which isn't really the case), so I tried making a disk image in Disk Utility of both disk2s10 and disk2s4. I tried opening disk2s10.dmg in Finder and in Disk Utility, and get the message: "No mountable file systems." In the past when confronted with unmountable disk images, I've used VLC media player. So, I pull up VLC read disk2s10.dmg and music starts playing!!! At first I freak out, then I realize that its the first song listed in my iTunes library -- the data is there, can be retrieved, but I'm not sure how to get it!
    *Next attempts:* the only other thing I can think of is to try daemon tools or something on my PC, or bring the drives into the the school IT guys.
    Please let me know what you think would work that I haven't already tried. Though I have redundancy in the backups, I haven't been able to recover some data for my PhD thesis due in a month, and therefore haven't given up on reviving this disk yet.

    I've downloaded the DataRescue and FileSalvage trials, and am currently scanning with DataRescue which will take another few hours. Thanks for those recommendations, its so useful to have a trial scan before buying.
    *General Question:* I noticed through these various attempts that reformatting extra drives in the current version of Disk Utility has become a little more dangerous than before. For example, I was reformatting a spare disk from FAT32 to HFS+ and the drive became unmountable. This never happened to me in earlier versions of OSX, and now it seems to happen every time, and partly why my partitions got all screwy. Any thoughts?

  • Trouble with encryted disk image

    OK.. here it goes. I'll start with expected "I'm new to Macs". I recently purchased my first Mac. Its an iMac running Snow Leopard 10.6.2. In the interest of securing my personal files I wanted to create an encrypted disk image to store them. So I opened up Disk Utility and with Macintosh HD highlighted in the left column I selected the "New Image" button. I think that was my first mistake, selecting the "New Image" button when Macintosh HD was highlighted because the resulting dialog only offered me Save As, Image Format and Encryption. It did not offer me Size, Format or Partitions. I selected to save the image as "Vault" in my Documents directory, and I chose compressed and 128 bit encryption.
    Next I hit create and entered my administrator password and provided a password for encryption. It started chugging along and I noticed it was reading my entire Macintosh HD. The process took a good while. Finally it completed and as a result there was a (roughly) 150 GB .dmg image in my documents directory with the name I provided (Vault.dmg). FYI.. I had about 150GB of data on my HD when I started this little adventure.
    Moving right along, when I tried to mount the disk I get an error saying "..(no mountable file systems". Here is the log output from disk utility:
    ===== Saturday, February 6, 2010 7:34:24 AM MST =====
    2010-02-06 07:34:26 -0700: Attach Image “Vault.dmg”
    2010-02-06 07:34:26 -0700: Initializing…
    2010-02-06 07:34:28 -0700: Verifying…
    2010-02-06 07:34:28 -0700: Verification completed…
    2010-02-06 07:34:28 -0700: expected CRC32 $31E027DA
    2010-02-06 07:34:28 -0700: Attaching…
    2010-02-06 07:34:28 -0700: Mounting…
    2010-02-06 07:34:28 -0700: Attaching…
    2010-02-06 07:34:28 -0700: Finishing…
    2010-02-06 07:34:29 -0700: Unable to attach “Vault.dmg.” (no mountable file systems)
    2010-02-06 07:34:29 -0700:
    FYI.. after I tried to mount the disk image via the disk utility I see a ghosted "Macintosh HD" appear under my Vault.dmg. To make matter worse I can't erase either of these because everything on the Erase tab is disabled (grayed out). So at this point I'm pretty sure I created a compressed disk image that has a copy of all my data which is not what I wanted.
    At this point I just want to erase this ridiculously large and unmountable disk image, and start over. Can any of you fine people help me?
    Thanks.
    Message was edited by: docdee24

    Some systems will auto open. With my settings, I right click and mount the disc image, then play. When I'm finished, I eject the "disc." If you're not ejecting the mounted image, perhaps the Mac is confused about which disc to play.
    John

  • Problems unmounting/ejecting a disk image after upgrade to 10.4.9

    Since I upgraded to 10.4.9 I have the following problem:
    After viewing a slideshow of pictures located in a disk image I cannot unmount/eject this image. I receive an error message that the image cannot be deactivated/ejected as some file is still in use.
    Using the activity monitor I checked which files are in use by the Finder and found out that the last picture shown by slideshow is still referenced.
    To me it seems as if the upgrade from 10.4.8 to 10.4.9 either changed the behaviour of slideshow (which does not close all files when terminated) or the eject image function (which does not force all open files in the image being closed).
    The only bypasses I found so far are
    - using "umount -f" on Unix level (think I have to be an admin for that)
    or
    - logging off and on again / restarting the computer
    Has anybody got other ideas how to force the unmount without using native UNIX commands in a terminal window?
    Can someone tell me how I can report this bug to apple? On Apple's support pages I could not find any information on that.
    Thanks in advance for any helpful hints.
    iMac 20" intel   Mac OS X (10.4.9)  

    The "Dock" contextual menu item to "Relaunch" the "Finder" is the equivalent of a "Force Quit", which is quite different from a regular "Quit".
    Unless it is being unresponsive to a normal "Quit" signal, force quitting any application is not recommended because unsaved changes will be lost. In the case of the "Finder", any sort of file transfers in progress will be interrupted. Data loss may also occur if a file containing "comments" has been moved at some point earlier in the login session.
    A normal "Quit", such as what occurs when logging out, quitting through the menu, using AppleScript or the "Quit" option of "Activity Monitor.app" ensures that the app quits in an orderly manner.

  • Disk Image of unmounted Macintosh HD

    So I was using my Mac and it suddenly shut down. When I went to restart it, it got stuck on the grey screen and the Apple logo turned into a no access symbol (circle with horizontal line through it). I booted into Recovery, and used the Disk Utility only to find that "Macintosh HD" is unmounted and greyed out. In addition to this, I cannot verify or repair the disk because all of those options are also greyed out. However, I noticed that "500.11 GB Toshiba MK5065GSXF" wasn't greyed out, so I tried to verify and repair that - which failed.
    Before I take it into an Apple store I want to create a disk image of Macintosh HD so I can restore all my current data (I already have a time machine back up but its a bit old). Anyway, my main question is, will creating a "new image" of 500.11 GB Toshiba MK5065GSXF and saving it onto an external hardrive work? Or does the image have to be specifically from the Macintosh HD partition? I can't even create a "new image" from Macintosh HD, all options are greyed out!! I'm really confused. I've already read through a few other posts already but I'm still unsure of what to do. Any help would be really appreciated!
    My computer is running Mac OS X Lion and has File Vault enabled.

    Is there a solution to this at all?

  • Disk images won't unmount/eject for admin user, DVDs & iDisk also affected

    This problem started when I was on Tiger, and seemed to follow me onto Leopard.
    It only affects me, the primary user on my Mac. *One other user on the computer; she also has admin level access and does not have any of these problems.*
    Here's the deal:
    *Once mounted, disk images won't eject/unmount.*
    - Dragging to the trash can doesn't work. The eject icon appears, but nothing happens.
    - Ctrl-click does not show Eject as an option when highlighting the mounted image.
    - CMD-E doesn't work
    - EJect doesn't appear as an option in the finder menu
    - Clicking on the Eject button in the sidebar of the Finder window doesn't work.
    - I've logged out, rebooted, repaired permission, and installed a new OS (clean install of 10.5, then did the import of my old user settings. Since I had the problem in Tiger, it's clear the problem followed me, but what the heck causes it?)
    *The only way to unmount/eject a disk image is to use the Disk Utility Program.*
    *DVDs also can only be ejected via Disk Utility*
    The iDisk connection can only be killed by opening Activity Monitor and killing the webdavfs_agent process.
    Would love some help. I've searched a lot and have a fair amount of folks with this problem, but no real solution.

    That'll work; however, then the OP has to reset all of his preferences. Easier would be to log into the newly created admin account, backup the bad account's folder, delete the bad account, selecting the save data option (which is stored in /Users/Deleted Users/ as a disk image), recreate the bad account using the same username/password combo, log out and back into the recreated original account. Mount the saved data dmg file in /Users/Deleted Users/, open the /Library/Preferences/ folder from the saved data, open the current /Users/restored account/Library/Preferences/ folder, and slowly copy plist files from the saved data folder to the current one. Log out and back in to ensure there's no conflict and things still work correctly. Resolving these kinds of conflicts is a laborious process, but not as laborious as resetting preferences or even remembering what you set weeks, months, or years ago.

  • Disk images suddenly will not unmount.

    One of several intermittent troubles I am having on my new 24" iMac with Leopard:
    suddenly when using disk images none will unmount. Only launching Disk Utility and unmounting them there works. Or logging out of my account. The eject symbol next to the disk image's name doesn't work. Dragging the disk image to the trash doesn't work either. If I have a disk image open and click eject it's Finder window closes, but he disk image remains mounted.
    Three wipes of the HD and reinstalls of Leopard have failed to fix this issue.

    I've got this one too. It also happens with external drives and not just disk images.
    I made a little apple script which ejects disks and disks images.
    on open some_items
    repeat with this_item in some_items
    try
    do shell script "hdiutil detach " & quoted form of POSIX path of this_item
    end try
    end repeat
    end open
    open the above in Script editor and save it as an application. Put this application (or an alias to it) on the desktop. To unmount one or more disks drop them onto this application (you can do it with several disks at once). I find that this works a bit faster than launching disk utility and ejecting the drives manually. Still, it would be preferable if they just fixed it.

  • Unmount disk after logout

    Hello,
    I am trying to figure out if it would be possible to somehow automatically unmount my iPod after I log out of my user. I have created my user home directory on my iPod (for mobility) and so I would like to unmount the iPod so I can unplug the iPod without having to login to another user and unmounting that way. I would appreciate if someone has some knowledge on how to perform this task.
    Thanks!

    I don't think it is possible. If your home folder was not on the iPod then you could write a script to unmount it before you log out. That won't work in your case, though. You might also consider the security implications of keeping your home folder unencrpyted on your iPod. If it gets lost or stolen, a thief has all access to all of your files.
    I have my home folder on the main hard drive in /Users. I regularly copy my whole home folder to an encrypted disk image on my iPod. The data is safe in the encrypted disk image. If I want to access any of the data from another Mac, I just hook it up, mount the image, and there's my whole home folder.

  • Hey People,  Disk Image?  Unmount?

    New to macs, wanted to use Toast to copy a DVD I get a message telling me "disk cound not be unmounted , all open files and programs on this volume must be closed first" So what does unmount mean and how do you do it? I've searched and can not find the answer, also what is a "disk image" ? I guess these things are so simple that theres no need to post the info anywhere, but I'm stumped.
    Powermac G4   Mac OS X (10.4.7)  

    A disk image file is a disk file containing a complete disk (including its own catalog of files in the disk image). When it is "mounted" (by double-clicking the disk image file) OSX treat the disk image file as if it were a disk drive. It will appear in the Finder sidebar (with an eject symbol next to it) and/or on the desktop, depending on Finder preferences. When it is dismounted, by selecting the file and pressing Cmd-E (eject), its icon disappears from the Finder sidebar and/or desktop, and the files it contains become unavailable to OSX.

  • Disk image in doc has to be replaced after each unmount

    Hello everyone,
    I have a disk image which I made in the disk utility program. I set it up with the security incription option when I make it. After opening it I placed the image that mounts up on the desktop into my dock so I can easily go through the sub menu folders and so on.
    When I was in os10.4.11 I had no problem going back into it after reboot or after unmounting the disk image and remounting it. But in 10.5.8 (which I am now using), every time I eject the image and remount it the fold in the dock does not work. I have to pull the folder (image) off the dock and drag the one from the desktop onto the dock every time. Is there any way to fix this?
    Thank you for any help.
    Marco

    All the information is within the EDB file and I don't believe lower end tools like Stellar or others provide access to them and then there is the question of accuracy.  Our DigiScope tool the tools from Kroll and Quest are accurate and reliable and
    will give you access to all the recoverable items folders so you can export to PST and import as needed.   You can get a DEMO license for DigiScope which will allow you to open all the mailboxes and their associated Recoverable Items folder to ensure
    what you need is there before purchasing a license.
    Another option would be to see if Stellar exported any of the recurring meetings from the calendar.  You should be able to open the PST and see if any of the recurring items exists within the PST.  If they do then you might see about importing
    them from PST via Outlook and then once in place open the items to ensure they are set to be recurring and if not have the user adjust the recurring settings.
    Search, Recover, & Extract Mailboxes, Folders, & Email Items from Offline Exchange Mailbox and Public Folder EDB's and Live Exchange Servers or Import/Migrate direct from Offline EDB to Any Production Exchange Server, even cross version i.e. 2003 -->
    2007 --> 2010 --> 2013 with Lucid8's
    DigiScope

  • Cannot unmount any disk images

    Hey guys, I've a problem. I can't unmount all the disk images that I've mounted. The same thing with usb external drives.
    The only way to eject is going to utility disk and unmount the images frome there. It's really annoying... Anyone can help me? I'm not sure, but i think that the problem was due to of cocktail software.. I set all the default setting but the problem isn't solved...
    thanks for your help.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you boot, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Mounted disk images wont eject or unmount

    I have a problem where when I mount a disc image, after installing the software, I cannot eject or unmount the image. Dragging the mounted image to the Trash does nothing.
    I can successfully unmount the images from Disk Utility but it's a bit of a hassle to fire up an application just to unmount an image.
    Anyone else have this problem or any ideas how to fix it ?

    Hey Ken, thanks for all your advice and input. Cheers.
    PS - do you ever sleep ?
    My user name is Mitch - no spaces or non alpha but it does have a Capital M. Is this likely to cause a problem ?
    I am the holder of the admin account as well.
    I haven't reset my PRAM but I have repaired my disk to no effect.
    My original install was a completely fresh install after a 7 pass erase of my HD. The update to 10.5.1 was via software update.
    When I get home tonight I will download the stand alone 10.5.1 updater and reset the PRAM.
    This problem isn't a show stopper by any means as I can eject via disk utility but I'm just curious as to what is causing the problem.
    As an aside, CD's and DVD's eject fine.
    As far as Time Machine is concerned, I have been a long time user of Retrospect Express and I definitely prefer the control Retrospect has over what gets backed up over Time Machine. I also find Time Machine much slower backing up than Retrospect so I think I'll go back to Retrospect. My main backup needs are iTunes and iPhoto and it's quite difficult using Time Machine to exclude everything except those 2 libraries.
    regards
    Mitch

Maybe you are looking for

  • HP SMART WEB PRINTING CLIP OPTION IS NOT WORKING

    I have ie 7 & xp.  i click select. the clip/print option pops, i click clip and nothing happens.  When I click community forum, microsoft visual c+++ run time library pops up & states:runtime error! program c:\program files\internet explorer\iexplore

  • Manually recorded audio is being truncated at beginning

    I'm recording narration for a Captivate 3 movie of a software demo. After I record the audio for a slide, I use the built-in audio editor to replace the "ramp-up" (noise) at the very beginning of the recording (usually about 0.7 seconds before the vo

  • Antique Contrast on selected areas of image

    I have done this once before and can not for the life of me remember how I done it. I have an image with the main subject (a car) and the background which I wish to have set to a Antique Contrast type effect.  I think this is what it was called as I

  • Yahoo. When I try to open my mail I can see the folds but can't open the individual mail.

    I see the folder with empty displayed on the right but I can't open the mail.

  • Need a tip for Labview

    Hi I need to know the place in the web where I can find Labview examples. I have been in National Instrument's web page but I couldn't find the examples.I will appriciate to have the link. Thanks, Arash