There is no windows built-in command to do this, but you can make use of a third party utility called nircmd.exe for this purpose. Download a copy of it from http://nirsoft.net and execute the below commands
To open …
nircmd.exe cdrom open D:
To Close …
nircmd.exe cdrom close D:
Where d: is your cd drive letter.