DOCUMENT:Q77856  17-DEC-2000  [msdos]
TITLE   :IF EXIST Finds Hidden and System Files
PRODUCT :Microsoft Disk Operating System
PROD/VER:MS-DOS:5.x,6.0,6.2,6.21,6.22
OPER/SYS:
KEYWORDS:

======================================================================
-------------------------------------------------------------------------------
The information in this article applies to:

 - Microsoft MS-DOS operating system versions 5.0, 5.0a, 6.0, 6.2, 6.21, 6.22 
-------------------------------------------------------------------------------

SUMMARY
=======

The IF EXIST command finds system and hidden files. You may encounter a
situation in which IF EXIST finds a file and then the specified action on that
file fails. It is possible that the IF EXISTS command is finding a file with
hidden or system attributes and the specified action fails on a hidden file.

MORE INFORMATION
================

To duplicate this problem, create a file called TEST.TXT and give the file
system or hidden attributes using the ATTRIB command. Next, execute the
following command:

   if exist test.txt del test.txt

Upon execution, the above command will return

   FILE NOT FOUND
   Access Denied

The IF EXIST command finds the file even though it has a hidden attribute, but
the DEL command does not recognize hidden or system files. The solution is to
remove the system and/or hidden attributes. The IF EXIST command will then
function correctly.


Additional query words: 6.22 5.00 5.00a 6.00 6.20

======================================================================
Keywords          :  
Technology        : kbMSDOSSearch kbMSDOS621 kbMSDOS622 kbMSDOS620 kbMSDOS600 kbMSDOS500 kbMSDOS500a
Version           : MS-DOS:5.x,6.0,6.2,6.21,6.22

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.  MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 2000.