I’d like to create a small application with node.js that would look something like this:
console.log("Creating extra beer holder...");
EjectCD();
Does such functionality already exist, or will it be necessary to create some sort of C++ binding to do this?
You can do this by taking advantage of the fact that node.js runs in an environment console. That said, it will only open the drive on your server, and is dependant on your server’s OS. The following should (I have no cd drive to test) work in a linux environment where your cd drive is mounted as “cdrom”:
This page gives more info on the linux eject command: http://linux.about.com/od/commands/l/blcmdl1_eject.htm
There is no native windows command line command for eject, but there are a number of simple executables you could place on your server to accomplish this, for example http://www.nirsoft.net/utils/nircmd.zip, which would take the command: