JSI Tip 5533. Why can't I delete a file in Windows 2000 or Windows XP?
July 18, 2002
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 . 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 "\?path_to_file.extension" to delete the file.
6. The file name contains a trailing space.
Use del "\?path_to_file.extension " to delete the file.
7. You may have to use SubInAcl:
(SubInACL /onlyfile "\?path_to_file.extension" /setowner=DomainNameDomainAdminName /grant=DomainNameDomainAdminName=F) to take ownership of the file and grant permission, if you have a combination of the above reasons. You would then use del "\?path_to_file.extension" to delete the file.
About the Author
You May Also Like