MacBook: Script to Eject CD-ROM under Vista

Posted on March 26th, 2007 in MacBook, Vista by amida168


The MacBook has no eject button under Vista. The eject key doesn’t work either. To eject CD-ROM, you need to use Windows Explorer. Once you have Windows Explorer opened up, you need to right click on the optical drive and select “eject” assuming you have an external mouse. If not, you will need to run a 3rd party utility like applemouse.exe to simulate the right mouse click. Anyway, there are multiple steps involved just to eject CD-ROM.

I found a VBscript to eject CD-ROM. When I tried the script on my MacBook, it didn’t work. After experimenting a bit, I got the code to work. Here is the modified version.

Const CDROM = 4
For Each d in CreateObject("Scripting.FileSystemObject").Drives
  If d.DriveType = CDROM Then
    Eject d.DriveLetter & ":\"
  End If
Next
Sub Eject(sDriveLetter)
  Dim ssfDrives
  Dim oShell
  ssfDrives = 17
  CreateObject("Shell.Application")_
    .Namespace(ssfDrives).ParseName(sDriveLetter).InvokeVerb("Eject")
End Sub

I created a shortcut to this script on the Quick Launch bar. Now, I can eject CD-ROM with just one mouse click. Also, remember that the items on the Quick Launch bar have keyboard shortcuts assigned to them. The keyboard shortcut is Windows key + Number where the number represents the order of the item on the Quick Launch bar. For example, the script to eject CD-ROM is the 7th item on the Quick Launch bar. I can use Windows key + 7 to invoke the script to eject the CD-ROM.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Live
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb
  • NewsVine

Random Posts

9 Responses to 'MacBook: Script to Eject CD-ROM under Vista'

Subscribe to comments with RSS or TrackBack to 'MacBook: Script to Eject CD-ROM under Vista'.

  1. Lethal.Liquid said,

    on March 31st, 2007 at 10:11 pm

    You can right click on macintosh with Ctrl + (Click), I’m not sure if this works under Vista.

  2. FirstKnight said,

    on April 13th, 2007 at 2:16 pm

    You got the short. How did you do it?

  3. Joe said,

    on April 22nd, 2007 at 12:48 am

    My drives letter is e could you make me one my emails jr318a@gmail.com

  4. amida168 said,

    on April 22nd, 2007 at 9:19 am

    Joe,

    Just create a script called eject.vbs and past the following code in it.

    ’start of the script

    Eject(”e:\”)

    Sub Eject(sDriveLetter)

    Dim ssfDrives

    Dim oShell

    ssfDrives = 17

    CreateObject(”Shell.Application”)_

    .Namespace(ssfDrives).ParseName(sDriveLetter).InvokeVerb(”Eject”)

    End Sub

    ‘end of the script

  5. Tey' said,

    on January 26th, 2008 at 2:24 pm

    Thanks for the script. Note however that the verb name “Eject” depends on your OS language. For instance, with the French version of Windows, it’s called “Éje&cter”.

  6. Jonathan PH said,

    on June 5th, 2008 at 12:06 pm

    You can right click in windows on a macbook by putting both fingers on the touchpad and clicking.

  7. Chuck said,

    on December 5th, 2008 at 8:50 am

    I copied the script on this page and and didn’t work. I tried amida168’s script and it didn’t work either. Am I missing something? Also, what’s “Eject(”e:”)” supposed to do? As far as I know, that isn’t a valid VBS function.

  8. amida168 said,

    on December 5th, 2008 at 11:02 am

    If you just copy and paste the code, it’s not gonna work. The blog software has added some extra lines and make the script not working. I fixed it and it should work now. Eject is a subroutine defined in the script. It’s used to eject the CD-ROM.

  9. karl said,

    on December 15th, 2008 at 5:49 pm

    This script worked for me. Thanks a lot!

Post a comment