MacBook: Script to Eject CD-ROM under Vista

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.