# Batch file to open optical disk drives



## temporary (Aug 29, 2006)

I wanted to know if anyone can tell me how I can call upon the MCI to open/close the main optical disk drive.

The following link seems to offer some way of doing it in a regular program I think, but I couldnt get the offered commands to work in either cmd or a batch file.

http://nsis.sourceforge.net/wiki/Open_&_Close_Optical_Disk_Drive

Any help would be greatly appreciated!


----------



## blaqDeaph (Nov 22, 2005)

I don't think that those commands are meant for batch programs. You probably have to use rundll32.exe to run the functions directly from the command line.


----------



## Squashman (Apr 4, 2003)

Plenty of free command line tools to do this. You could also do it in Vbscript. A quick Google search will find you the answers.


----------



## temporary (Aug 29, 2006)

blaqDeaph, that info you gave me on the rundll.32 is great. I can use the dll commands in a batch file that offer poweful capabilities. I dont think I see one though that can open disk drives.


----------



## blaqDeaph (Nov 22, 2005)

temporary said:


> blaqDeaph, that info you gave me on the rundll.32 is great. I can use the dll commands in a batch file that offer poweful capabilities. I dont think I see one though that can open disk drives.


It's a matter of locating the dll that the function is stored in, and passing that to rundll32. You can do things like shutdown the computer etc. I myself can't remember exactly where the function is located. Why don't you look at the MSDN's website for the MCISendCommand() function, and see where that's located.


----------



## Squashman (Apr 4, 2003)

http://www.myitforum.com/inc/upload/6416eject.zip

or Vbscript.


```
Const ssfDRIVES = &H11  
Const cdromDrvLtr = "D:\" 

  Set oSH = CreateObject("Shell.Application") 
  oSH.NameSpace(ssfDRIVES).ParseName(cdromDrvLtr).InvokeVerb "E&ject"
```


----------

