Shortcuts to Eject and Close CD/DVD Drive in Windows

Windows already includes the Eject command in the context menu for optical drives. If you want to add the Close Tray option in the context menu for optical drives, then this article is for you.

NirCmd is a small command-line tool that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your internet account or connect to a VPN network, restart windows or shut down the computer, create shortcut to a file, change the created/modified date of a file, change your display settings, turn off your monitor, open the door of your CD-ROM drive, and more…

Shortcuts to Eject / Close CD/DVD Drive

Download from, unzip and extract the files to a folder. Move the file nircmd.exe to your Windows directory. To create a desktop shortcut to eject the CD/DVD drive tray, use the following command:

nircmd.exe cdrom open drive:

Assuming that F: is the drive letter for your CD/DVD drive, you use the following command:

nircmd.exe cdrom open F:

As you guessed it right, the command for closing the drive tray is:

nircmd.exe cdrom close F:

Fig 1: Desktop shortcuts to open and close CD drive.

Tip: You may customize the icon the shortcuts accordingly. Browse through shell32.dll using the Change Icon dialog, and pick the CD/DVD icon. (Icon index #11)

Add “Close Tray” option to the context menu

To add a Close Tray entry to the right-click menu of CD/DVD drives, use these steps:

  1. Download and save to Desktop
  2. Unzip the files and extract the contents to a folder
  3. Double-click closetray.reg to run it.

The Close Tray option will now appear for all optical drives connected to the system. Note that there is also a undo .reg file available in the zip just in case you want to remove Close Tray option from the right-click menu.

The above is just one of the many tasks that NirCMD can automate. Read the nircmd help file to know the other uses of this excellent tool!

One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded in 2005.

8 thoughts on “Shortcuts to Eject and Close CD/DVD Drive in Windows”

  1. downloaded and unzipped the close tray, and the close tray shows up now, but when I use it Windows asks what program I want to open the file with….

  2. the option for closing the drive trays is now there when I go to “my computer” and right click on either of my drives but after opening the drive(s), the close feature doesn’t work and the error is saying “application not found”

  3. I added an open CD option so open and close are together. Now is there a way to remove the existing Eject option from the menu?


Leave a Comment