Detect the cd-rom drive letter in batch file..
Posted: 08 Dec 2009 15:14
Need to auto-install a bunch of sfx files from a cd-rom drive and not off the hard drive. If anyone has done this let me know. I have a code that runs off the Hard drive but errors out when trying to find the cd-rom drive.
Code: Select all
@ECHO OFF
cls && Color 4f
echo |set/p=Date and Current Time: %DATE% & TIME/t
echo.
echo.
echo Auto-Installing Applications from CD Drive
:start
echo.
echo Enter your CD-ROM/DVD drive letter (D,E,F,G,H,I,J,K) then press Enter
@echo off & setlocal
:LOOP
set /p drive=
if ‘%cdrom%’ == ‘D’ goto proceed
if ‘%drive%’ == ‘E’ goto proceed
if ‘%drive%’ == ‘F’ goto proceed
if ‘%drive%’ == ‘G’ goto proceed
if ‘%cdrom%’ == ‘H’ goto proceed
if ‘%drive%’ == ‘I’ goto proceed
if ‘%drive%’ == ‘J’ goto proceed
if ‘%drive%’ == ‘K’ goto proceed
if ‘%drive%’ == ‘d’ goto proceed
if ‘%drive%’ == ‘e’ goto proceed
if ‘%drive%’ == ‘f’ goto proceed
if ‘%drive%’ == ‘g’ goto proceed
if ‘%drive%’ == ‘h’ goto proceed
if ‘%drive%’ == ‘i’ goto proceed
if ‘%drive%’ == ‘j’ goto proceed
if ‘%drive%’ == ‘k’ goto proceed
cls
goto error
:error
echo.
echo The drive letter you entered was not recognized
echo.
pause
cls
goto start
:proceed
cls
echo.
echo Would you like to Begin Installs from this Drive %drive%:?
echo.
echo Type Y for Yes or N for NO then press ENTER
set /p ok=
if ‘%ok%’ == ‘y’ goto yes
if ‘%ok%’ == ‘Y’ goto yes
if ‘%ok%’ == ‘n’ goto no
if ‘%ok%’ == ‘N’ goto no
cls
:yes
ECHO Installing App1...
start /wait %CDDRIVE%\Installs\app1.exe
ECHO Installing APP2...
regedit /s %CDDRIVE%\Installs\app2.exe
ECHO Installing APP3...
regedit /s %CDDRIVE%\Installs\app3.exe
END