Ejecting Removable Media from the Command Prompt


How often have you wanted to be able to eject a CD, disconnect an MP3 player / USB key, etc., from the command line?

With a small little utility (courtesy of Microsoft (and me)), you can!

Knowledge Base article 165721 explains how to do this in Windows NT, 2000, and XP. They give some sample source code, which you can download and compile.

Or, you can download the same thing here!

I took their code, changed two calls to wsprintf to use sprintf, and compiled it using cl eject.c to compile with the command line compiler from Visual Studio 6.

Download source: eject.c and executable: eject.exe

For anyone who can compile this themselves, I would encourage you to do so. For anyone who can’t, you can use the compiled executable here (usual warnings about trusting executables downloaded from the Internet, etc, etc)


One response to “Ejecting Removable Media from the Command Prompt”

Leave a Reply

Your email address will not be published. Required fields are marked *