Eject CD/DVD Drive: Desktop Context Menu Guide

Ejecting CD/DVD Drives Without a Physical Button
Typically, optical drives like CD/DVD drives are ejected using a physical button located directly on the drive itself.
However, many laptop computers are designed without this dedicated button for a sleeker profile.
Ejecting from the Desktop
Fortunately, it's possible to eject the drive directly from your desktop environment.
This method provides a convenient alternative when a physical eject button isn't available.
Safely Removing USB Drives
Alongside optical drive management, the safe removal of USB drives is also crucial for data integrity.
Properly ejecting USB drives prevents data corruption and ensures the longevity of the storage device.
We also offer guidance on how to safely eject USB drives from your desktop.
This ensures that all write operations are completed before the drive is disconnected.
- Safely removing drives minimizes the risk of losing important files.
- It also helps to avoid potential hardware issues.
Enhancing Desktop Functionality: Adding an Eject Option to the Context Menu
Begin by visiting the NirSoft website to download a copy of nircmd; ensure you select the version compatible with your operating system’s architecture.

Once downloaded, extract the nircmd.exe file and place it within the C:\Windows\System32 directory.

After copying the file, right-click on it and choose 'Properties' from the resulting context menu. Within the Properties window, click the 'Unblock' button if it is available.

Next, launch Notepad with administrative privileges. This can be achieved by right-clicking the Notepad icon and selecting 'Run as administrator' from the context menu.

Copy and paste the following code block into the newly opened Notepad window.
Important: Remember to replace the drive letter ('d:') in lines 5 and 9 with the actual drive letter assigned to your CD/DVD drive.
@ echo offIF EXIST %TEMP%\DVDOPEN GOTO :CD/DVDCLOSE:CD/DVDOPENecho 1 > %TEMP%\DVDOPENstart "" nircmd.exe cdrom open d:exit:CD/DVDCLOSEDEL %TEMP%\DVDOPENstart "" nircmd.exe cdrom close d:

From the File menu, select 'Save As'. In the Save As dialog, change the 'Save as type' dropdown to 'All Files'.

Navigate to the C:\Windows\System32 directory and save the file as open.bat.

With the file saved, open the Registry Editor. Navigate to the following key: HKEY_CLASSES_ROOT\DesktopBackground\Shell.

Right-click on the 'Shell' key and create a new key named 'Eject/Close CD/DVD Tray'.

Within the newly created key, create a new String Value and name it 'icon'.

Double-click the 'icon' value and enter the following data into the 'Value data' field:
imageres.dll,-30

Now, right-click on the 'Eject/Close CD/DVD Tray' key and create another new key, naming it 'command'.

Open the 'command' key and modify the 'Default' value. In the 'Value data' field, type open.bat.

The process is now complete.