Computer Hope

Microsoft => Microsoft DOS => Topic started by: George Zaha on October 25, 2004, 07:34:05 AM

Title: Avoid Abort, Retry, Fail on CD "if exist"
Post by: George Zaha on October 25, 2004, 07:34:05 AM
I want to test if a file exists (by using "IF EXIST" or some other alternate) on a data CD without geting the "Abort, Retry, Fail" message in case I forgot to insert a CD into the CD-drive. Is there a way to do this?

I guess what I'm really asking "Is there a way to test if a CD has been inserted into a CD-drive?".
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: scruge on October 25, 2004, 08:10:07 AM
I don't think so, unless there is a command.com switch that can be set to run in silient mode..   a disk error is a major show stopper for any os.  You may be able to find an external utility that you could call that would finger the drive by going around the os and leaving a error code that you could process with your batch.
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: ezaha on October 25, 2004, 12:36:17 PM
Thanks. I was affraid there was no easy solution.
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: scruge on October 25, 2004, 04:01:21 PM
I happened to come across a guy whos got tons of dos utilities.. maybe you can find what you need there.
http://www.opus.co.tt/dave/indexall.htm
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: Computer_Commando on October 25, 2004, 06:39:19 PM
Here's more:  http://www.oldfiles.org.uk/powerload/index.htm
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: ezaha on October 26, 2004, 08:38:31 AM
From scruge: This is a great site: for dos utilities and other info. http://www.opus.co.tt/dave/indexall.htm

There are lots of neat things. To answer my current issue, your suggestion had a link to http://home7.inet.tele.dk/batfiles/
And there under FAQ1 link I found to batch files that check for valid drives (item 43 and 44) that I was able to tweak to meet my needs. The key was the use of ctty nul|con , command.com using the "/f" option piped to find and choice.

Thanks to all who offered suggestions.

Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: ezaha on November 04, 2004, 08:58:55 AM
I have revisited this issue. Read on for a solution:

After using the suggestions (and web sites listed) in this forum, I have attached a simple batch file (ifExist.bat) that safely test for the existance of any file (with or without a full path), drive, or folder. Here is an example of how to "call" the batch file from within another batch file:

...
call IfExist myfile rc
if %rc% == 0 echo File 'myfile' FOUND
if not %rc% == 0 echo File 'myfile' NOT FOUND
...


------------------------------ BATCH FILE ----------------------------------
:: IfExist.bat
::
:: PURPOSE: Equivalent to the DOS 'IF EXIST ...command.
::  Runs on Windows 98SE and XP.
::
::  IfExist.bat safely tests for the existance of any file (or drive)
::  on any device (Floppy, HD, CD, DVD, ...) without fear of getting
::  the dreaded DOS  'Abort, Retry, Fail?' error message. This
::  error message can occur in DOS if the device (e.g., Floppy)
::  is not present.
::
:: SYNTAX:    IfExist [drive][folder][file] var
::          drive   - drive (e.g., a:, b:, ..., Y:, Z:)
::          folder  - folder
::          file       - file name
::          var      - name of environmental variable to
::                  hold the return code (e.g., rc)
::
:: On return, IfExist.bat sets the return code (var) to:
::  0 - if 'exist'
::  1 - if 'non-exist'
::
:: LAST MODIFIED: 11/3/04

@echo off

if %2x == x goto err1

::Init return code to 'non-exist'
set %2=1

::Use ctty nul (disconnect from the standard output). This
:: has the effect of hidding error messages in DOS.
:: %OS% is null for DOS not null for XP (not perfect).
:: ( XP does not support ctty; fortuneatelyt XP doesn't produce
::  the error messages we want to hide)
if %OS%x == x ctty nul

:: Use COMSPEC and DIR to find this file.
::
::Use command.com with the un-publish /f option to force
:: selecting "fail" if an abort-retry-fail error occurs.
%COMSPEC% /F/C DIR %1 | find /i "file(s)" > nul
if not errorlevel 1 if errorlevel 0 set %2=0

::Use ctty con to unhide error messages in DOS.
if %OS%x == x ctty con

goto END

:err1
echo.
echo   ---- SYNTAX: %0 [drive][folder][file] var
echo   --- ENTERED: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
echo         ERROR: Missing var (name of environmental variable to
echo                hold the return code (e.g., rc). Return codes of
echo                0 or 1 means 'exist' or 'non exist', respectively.
echo      EXAMPLES: %0 f1 rc
echo                %0 K: answer
echo                %0 \bin answer
goto END

:END

Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: Mohammed Shaker on November 06, 2004, 06:29:33 AM
Dear Sir,
I would like to setup win XP using a batch file that contians the serial No. of the setup and regional settings of Egypt . It is easy to do that for Win Me & Win 98.
Regards,
M.Shaker
Title: Self installation for win xp
Post by: Mohammed Shaker on November 06, 2004, 06:45:58 AM
Dear Sir,
I would like to setup win XP using a batch file that contians the serial No. of the setup and regional settings of Egypt . It is easy to do that for Win Me & Win 98.
Regards,
M.Shaker
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: George Zaha on November 06, 2004, 07:12:59 AM
I do not have the answer to your question.

To get maximum exposure, you may want to open a separate question rather than include your issue as part of this thread.

George
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: ezaha on November 06, 2004, 07:19:13 AM
Mr. M.Shaker

I do not have the answer to your question.

To get maximum exposure, you may want to open a separate question rather than include your issue as part of this thread.

George
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: John H on November 07, 2004, 11:19:40 AM
I have the same problem.

I found this,
http://www.robvanderwoude.com/files/driverdydos.txt

But I get an error message.

Anyone see a problem with this?
C:\COMMAND.COM /F /C DIR R: 1> NUL 2> C:\CDROM.TXT

It says TOO MANY PARAMETRES -1

It checks to see if there is a CDROM in the R: drive, if there isn't it will create a file called CDROM.TXT on the C: drive.
Title: Re: Avoid Abort, Retry, Fail on CD "if exist&
Post by: John H on November 07, 2004, 11:20:24 AM
No matter if there is a CD rom in the drive or not...it still makes the CDROM.TXT file.

Something must be wrong...anyone see it?