How-To Geek

How to Eject Your CD/DVD Drive From the Desktop Context Menu

Most of the time you’ll eject the CD/DVD drive on your PC through a button on the drive, but some laptops don’t include a button. Here’s a way to do it right from the desktop.

If you’d like to safely eject USB drives from your desktop, we’ve got you covered with that one too.

Adding Eject to the Desktop Context Menu

Head over to the NirSoft website and grab a copy of nircmd, remember to get the version that matches your operating system’s architecture.


Extract the file called nircmd.exe and paste it in the C:\Windows\System32 directory.


Right click on the file and select properties from the context menu, once the properties have opened click the unblock button.


Now open an administrative notepad, by right clicking on it and choosing run as administrator from the context menu.


Paste the following into the new document.

Note: You should substitute the drive letter on lines 5 and 9 for the letter of the CD/DVD drive that you wish to open and close.

@ echo off
echo 1 > %TEMP%\DVDOPEN
start "" nircmd.exe cdrom open d:
start "" nircmd.exe cdrom close d:



Select file and choose save as from the menu. When the save dialog box appears, change the type to all files.


Now navigate to C:\Windows\System32 and save the file as open.bat


Once the file is saved open the registry editor and navigate to HKEY_CLASSES_ROOT\DesktopBackground\Shell.


Right click on the shell key and create a new key called Eject/Close CD/DVD Tray.


In the key we just created create a new string value and name it icon.


Double click on the icon value and in the vale data box type



Now right click on the Eject/Close CD/DVD Tray key and create a new key and call it command.


Open the key and edit the keys “Default” value. In the value data field type open.bat.


That’s all there is to it.

Taylor Gibb is a Microsoft MVP and all round geek, he loves everything from Windows 8 to Windows Server 2012 and even C# and PowerShell. You can also follow him on Google+

  • Published 11/17/11

Comments (12)

  1. Maggy Stricker

    Somehow my child pulled out the entire cd/dvd unit from my Gateway laptop. I was able to slide it back in and the cd works fine, but not so for the dvd player. I’ve tried tweaking the driver to no avail. Do I have to bring it to the shop or can I fix it myself?

  2. iam_urz

    ok. so i’ll just wait till someone figures out a way to do this with one double click install.

  3. annon

    whats wrong with right clicking the drive in explorer and EJECT?

  4. root666

    What’s wrong with clicking the eject button on the drive? ^^

  5. Spen

    I can click the eject button on the drive but I can’t close it that way. Does any one know how to close it via the computer, that doesn’t mean downloading software?

  6. sasquatch1955

    Way to hard of a method. Quicker and effective method.
    1. Open “My Computer”
    2. Right click and hold the icon for your DVD/CD drive.
    3. Drag to desk top, release mouse button and select, “Create Shortcuts Here”
    4. Now you an icon for your drive on desk top and you can right click and select “Eject” from the menu.

  7. ronburns

    Nothing is wrong with any of those options, this one is faster for me because I purchased a BD that really doesn’t like to open when you push the eject button on the Dell Studio XPS 9100’s case. So, instead of having to open explorer, I can just use the context menu to do it. Thanks a lot for this reg hack!

  8. ronburns

    sasquatch1955: Your method doesn’t toggle open and close, it just opens it! So, I still agree with the context menu.

  9. Kathy

    Hey, thanks sasquatch1955
    I bought a new laptop& & the door to dvd player kept sticking. Sometimes you could get it open & most the time not. I didn’t want to return the laptop just for that, besides by the time I discovered the door didn’t work right (even poking into the little pinhole didn’t do the trick either) I had all my stuff transfered over & etc. I followed your advice it now pops open with a click. Thank you for your info. Really appreciate it.

  10. lance john

    thanks sas for helping open dvdin hp notebook ps anymore tips

  11. scouser73

    I downloaded the file and found that it contained Malware as detected by Comodo AV.

  12. Hariks

    eject -t in Ubuntu will toggle the CD tray open/close. Just create a launcher/easystroke for this and forget it. That is the beauty of Linux…

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!