
Batch file question (Yes, I know it's off-subject)
While I was in Florida for Thanksgiving vacation (and got to walk the
hurricane damaged Pensacola Beach), I installed a CDRom in my sister's
computer. My nephew gets upset because sometimes, when the computer boots
up, it does not recognize the CDRom drive. I gave them a autoexec batch
file revision that checks to see if there are any files in drive D: before
it starts windows, and if it does not find any, it instructs the user to
reboot the system (the second boot always works, they say). Here's
approximately what I sent them
AUTOEXEC.bat
(main commands deleted)
IF EXIST D:*.* GOTO CONTINUE
ECHO (instructions about rebooting)
GOTO DONE
:CONTINUE
WIN
:DONE
I'm not down there, so I can't test errorlevel's but what I'd like to do
is modify this code so that it checks the correct ERRORLEVELs for "Invalid
disk drive" versus "file not found" so that the batch file will work even
if a disk is not inserted in the drive. So, if someone has these numbers,
feed them to me. Then I can write a file more like this:
AUTOEXEC.bat
(main commands deleted)
DIR D:*.* > nul:
IF ERRORLEVEL n GOTO suchandsuch
IF ERRORLEVEL n-1 GOTO second
Code for every errorlevel < n
:suchandsuch
Code for every every errorlevel >= n
:second
Code for errorlevel n
If someone can feed me the error numbers, I'll be glad to repost the
entire batch file if requested. If I lived closer to them, I'd go down and
do this myself, and I don't know when I'll have my CDRom working again (my
old 2X stopped working, so I'm buying a new one rather than fix the old).
John