When enabling Bitlocker using Configuration Manager the step fails if there are a CD/DVD inserted. There are many great solutions to eject the CD/DVD before enabling Bitlocker out there.
As CD/DVD are not used at all that much anymore I was kind if annoyed that it ejected the CD/DVD every time and when enabling Bitlocker after OS deployment using a Task Seqeunce it could be interesting for the end-user when the CD/DVD is ejected.
So this script only ejects the CD/DVD when media is present in the drive. I have posted a powershell version on Microsoft Gallery: http://gallery.technet.microsoft.com/Eject-CDDVD-if-CD-present-5e464ad2
But after several requests I have created a vbscript version as well which also ejects the CD/DVD if media is present.
Download it here: ejectcd
Or copy paste the code below:
-------------------------------------------------------------------------------------------------------------------------------------
'Created by Jörgen Nilsson, https://ccmexec.com
'Version 1.0
On Error Resume Next
Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk where DriveType=5")
For Each objItem in colItems
cdpresent = objitem.access
driveletter = objItem.Name
Next
if cdpresent >0 then
CreateObject("Shell.Application").Namespace(17).ParseName(driveletter & "\").InvokeVerb("Eject")
Wscript.sleep 3000
end if
WSCript.Quit