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 utility written by Nir Sofer 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 Nircmd.zip from Nirsoft.net, 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:
As you guessed it right, the command for closing the drive tray is:

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 closetray.zip and save to Desktop
2. Unzip the files and extract the contents to a folder
3. Double-click closetray.reg to run it.

Fig 2: Close Tray option in the context menu
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.
Editor’s note: 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! And NirCMD is just one of the many helpful tools produced by Nir Sofer.
Bookmark this Page!
BlinkList | del.icio.us | Digg it | Furl | reddit | Spurl | StumbleUpon |
Related Posts
- Disable Empty Recycle Bin Confirmation in Windows XP and Vista
- Error “This File Does Not Have a Program Associated With It” When Launching a Game From Games Explorer
- Show the Window Menu (Restore, Minimize, Close) for Taskbar Icons in Windows 7
- How to Restore All Windows in a Grouped Taskbar Button in Windows 7?
- How to Create a System Repair Disk in Windows 7 and Vista
- Add “Open File Location” To the Context Menu for Shortcuts in Windows XP
- Determine the Target Path of Windows Installer Shortcuts
- Favorite Links Area in Windows Vista Explorer Is Empty
- Windows Vista Partition Not Seen From Windows 7 in a Dual Boot Setup
- Windows 7 USB/DVD Download Tool Creates Bootable USB Flash Drive
If you enjoyed this post, make sure you subscribe to our RSS feed! We feature Tips, Troubleshooting information, Scripts and Utilities for Microsoft Windows Operating Systems!
Prefer an E-mail subscription?

› 
I would like to know if you know of another way of adding this context menu WITHOUT having to download anything from the internet.
If you didn’t know, you can Close the CDDVD drive tray by opening Computer Management > Removable Storage > Libraries > ( right-click) on Media Device > Eject.
Where Media Device is your CD or DVD Drive
This will Eject the Media Device Tray. Right-click again on the Media Device and Eject is now replaced with Inject (Closes the Tray).
By clicking Inject, the Media Inject Wizard is launched in a new window. Click Next and Next again. The Media Device Tray will then close!
Obviously this involves a lot of key strokes, but it does demonstrate that with the correct and known commands/registry entries this can be turned into a right-click context menu for Inject.
Do you know how I can get this to work?