@echo off
set dn=66
set cdrom=
:count
strings dn=add %dn%,1
strings dr=char %dn%
xset /search "CDROM" drv drivetest %dr%
if not %drv%#==# goto ok
if %dn%#==90# goto no
goto count k
set cdrom=%dr%
echo The CD-ROM drive letter %cdrom% has been assigned to the variable "CDROM".
goto end
:no
echo No CD-ROM found!
:end
set dr=
set dn=
set drv=
echo.