Force eject disk with applescript

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

  1. masterp34588 macrumors newbie

    Joined:
    Aug 11, 2008
    #1
    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

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #2
    Very easy.
    Code:
    do shell script "drutil tray eject"
     
  3. Consultant macrumors G5

    Consultant

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

    Joined:
    Aug 9, 2009
    #4
    Apple provides an menu extra that adds an Eject icon to the right side of the system menubar.

    http://www.creativetechs.com/tips/quicktips_51.html

    Summary:
    Go to /System/Library/CoreServices/Menu Extras
    Double-click Eject.menu.
    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

    Joined:
    Jan 15, 2007
    #5
    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

    Joined:
    Aug 11, 2008
    #6
    Thanks so much!
     
  7. dXTC macrumors 68020

    dXTC

    Joined:
    Oct 30, 2006
    Location:
    Up, up in my studio, studio
    #7
    This rawks! Thanks!
     
  8. Damir Mustafic macrumors newbie

    Damir Mustafic

    Joined:
    Oct 2, 2009
    Location:
    Atlanta
    #8
    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

    Joined:
    Apr 25, 2011
    #9
    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.

    Alexandra
     

Share This Page