wonsleinad Posted May 20, 2005 Share Posted May 20, 2005 I am working on making a stardard dos bootup disk. In the autoexec file I am using this command to get the cd drive lettter:FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\whatever.txt SET CDROM=%%i:The problem I'm having is I have more than one CDROM drive, and when it gets to the second drive (with no disk present) it automatically says something like:Error Accessing E:\Abort, Retry, or Fail?Which messes up the automation of the autoexec. Is there a way that I can make the FOR command end as soon as it finds the first cdrom drive? I tried this but it did not work:FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\whatever.txt SET CDROM=%%i: && goto nextOR, would there be a way were it goes ahead and scans through all the drives, but continues regardless of an error? Link to comment Share on other sites More sharing options...
Martin Zugec Posted May 20, 2005 Share Posted May 20, 2005 Your syntax will work - just add to the next row :nextE.g. FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\whatever.txt SET CDROM=%%i: && goto SkipDetection:SkipDetection Link to comment Share on other sites More sharing options...
wonsleinad Posted May 20, 2005 Author Share Posted May 20, 2005 Your syntax will work - just add to the next row :nextNo, it doesn't, I tried that. It still continues to go through the rest of the alphabet even after matching the file. Then, after going through the alphabet it doesn't even set the variable, it tries to set the variable as "D: && goto next". It's weird, it will work in the XP version of the command prompt, but when I try it with the MS-DOS 7 boot disk, it doesn't.EDIT: I did accomplish the task with this command:SET CDROM=CIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=DIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=EIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=FIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=GIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=HIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=IIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=JIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=KIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=LIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=MIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=NIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=OIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=PIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=QIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=RIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=SIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=TIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=UIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=VIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=WIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=XIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=YIF EXIST %CDROM%:\whatever.txt GOTO doneSET CDROM=ZIF EXIST %CDROM%:\whatever.txt GOTO doneStill I would like to use the for command if at all possible. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now