Computer Hope
Microsoft => Microsoft DOS => Topic started 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?".
-
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.
-
Thanks. I was affraid there was no easy solution.
-
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
-
Here's more: http://www.oldfiles.org.uk/powerload/index.htm
-
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.
-
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
-
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
-
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
-
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
-
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
-
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.
-
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?