JSI Tip 5533. Why can't I delete a file in Windows 2000 or Windows XP?

There are a number of reason that a user or administrator can't delete a file:

1. The user or administrator does NOT have permission to delete the file.

You can try to use CACLS.EXE:

CALCS FileName /G Administrators:F

The above command will remove all ACLs on the file and grant the Administrators group Full Control.

2. The file is in use.

Close the file. You can use procexp.exe to determine the process that has the file open.

3. The file system is corrupts.

Run CHKDSK /F /R to detect and fix the corruption. CHKDSK may have to run at the next startup.

4. The path to the file is too long.

Use the 8.3 short name, unless it has been disabled. Type dir /x <full path to file>. If the 8.3 path is too long, start renaming parent folders until the path is short enough.

5. The file name / path contains a reserved named.

Use del "\\?\<Drive:>\path_to_file.extension" to delete the file.

6. The file name contains a trailing space.

Use del "\\?\<Drive:>\path_to_file.extension " to delete the file.

7. You may have to use SubInAcl:

(SubInACL /onlyfile "\\?\<Drive:>\path_to_file.extension" /setowner=DomainName\DomainAdminName /grant=DomainName\DomainAdminName=F) to take ownership of the file and grant permission, if you have a combination of the above reasons. You would then use del "\\?\<Drive:>\path_to_file.extension" to delete the file.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.