Force eject disk with applescript

Discussion in 'Mac Programming' started by masterp34588, Sep 24, 2009.

  1. masterp34588 macrumors newbie

    Aug 11, 2008
    I've spent the past 30 minutes toying around with getting applescript to run the following terminal command:

    "drutil tray eject"

    I would like this command to be in my applescript menu so whenever I get a CD stuck in my iMac (which is often) I can just run the applescript instead of having to google the command above. What's the easiest way to go about this? I'm on Snow Leopard.
  2. lancestraz macrumors 6502a


    Nov 27, 2005
    Very easy.
    do shell script "drutil tray eject"
  3. Consultant macrumors G5


    Jun 27, 2007
    Perhaps the source of the problem: don't scratch your cds?
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Apple provides an menu extra that adds an Eject icon to the right side of the system menubar.

    Go to /System/Library/CoreServices/Menu Extras
    Observe: Eject icon is added to menubar.
    Command-drag to move on menubar, or cmd-drag off menubar.

    I've been using the Eject menu-extra for a long time.
  5. foidulus macrumors 6502a

    Jan 15, 2007
    There are actually other reasons cds get stuck. At work some of our users switched to Vista(well, were forced to), and Vista by default writes disk in a flavor of UDF that only Vista supports. Leopard went nuts(disk utility thought there were a total of 4.1 billion files taking up 1 meg of space) and would not eject the disc through all the normal means. It had to be force ejected and that failed on occasion(had to bounce the machine and eject the disc before the OS booted). So there are other reasons for discs getting stuck....

    So maybe the real moral of the story is, "Take care of your optical media, don't scratch them and don't EVER let them anywhere near Vista" :p
  6. masterp34588 thread starter macrumors newbie

    Aug 11, 2008
    Thanks so much!
  7. dXTC macrumors 68020


    Oct 30, 2006
    Up, up in my studio, studio
    This rawks! Thanks!
  8. Damir Mustafic macrumors newbie

    Damir Mustafic

    Oct 2, 2009
    Eject disc on snow leopard doesn't work

    I installed SL, rebooted and my CD drive quit working.
    When booting I hear it initialize, but when I push the CD media in, it doesn't take it. I tried ejecting and when i press the eject key, I don't see the icon on the screen anymore.

    This happened right after the Snow install. Tried ejecting from shell, command executes but still can't "push" the media in.
  9. Alexandra Frei macrumors newbie

    Apr 25, 2011
    Great Help ...

    Many thanks buddy, I was nearly destroyed not to get out this dm... DVD, thinking in a computer GAU.
    But it was helping perfectly ... shhowww the disk was out.


Share This Page