Jump to content

Script for opening the cd tray after install


Recommended Posts

I thought there might be someone (like me) out there who doesn't want to open the CD tray manually when they're done installing so here is a windows script that ejects the cd tray.

open.vbs

Const CDROM = 4
For Each d in CreateObject("Scripting.FileSystemObject").Drives
 If d.DriveType = CDROM Then
   Eject d.DriveLetter & ":\"
 End If
Next

Sub Eject(CDROM)
 Dim ssfDrives
 ssfDrives = 17
 CreateObject("Shell.Application")_
   .Namespace(ssfDrives).ParseName(CDROM).InvokeVerb("E&ject")
End Sub

Link to comment
Share on other sites


Well, I thought I should also post one to close it.. This one is a bit trickier. First of all you need wshAPIToolkitobject.ocx (one option). Copy it into system32 and run regsvr32 wshAPIToolkitobject.ocx

close.vbs

Dim oATO 
Set oATO = WScript.CreateObject("wshAPIToolkitObject.ucATO", "")
Const ssfDRIVES = &H11

Const DriveTypeCDROM = 4
Set oFS = Wscript.CreateObject("Scripting.FileSystemObject")
Set oDrives = oFS.Drives    
For Each Drive in oDrives  
 If Drive.DriveType = DriveTypeCDROM Then
   cdromDrvLtr = ("Drive.DriveLetter")
 End If
Next

Set oSH = CreateObject("Shell.Application")
nRtn = oATO.CallAPI("WINMM.DLL", "mciSendStringA", "Set CDAudio door closed", 0, 0, 0)

wshAPIToolkitObject.ocx

Link to comment
Share on other sites

this is posted on http://unattended.msfn.org

Download: CDR - a command line CD Drive Ejector utility

CDR.exe is a command line utility which you can execute to eject one or more CD/DVD drives. This can be used as a replacement for the cd_eject.vbs script file, which wasn't all that great in terms of functionality. Use CDR.exe /? for a full list of switches and examples.

Why would you want to use this tool? This can be handy to eject your Windows XP CD before performing replace/delete commands in the Windows or System32 directories, in which case Windows File Protection can intefere at times when the CD is in the drive.

Usage: CDR.exe open ALL

Thanks to devil270975 for developing this tool for MSFN.org

IMO, this is easier :P

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...