On Windows XP I've made a copy of my home directory. Now I want to remove it, but there's a directory with two files which I can't get rid of:
N:\COPY-OF-HOME\Local Settings\Application Data\Microsoft\CardSpaceThe directory is read-only, and I can't change it (access denied). Cacls shows the following
Everyone:(special access:) READ_CONTROL SYNCHRONIZE FILE_READ_ATTRIBUTES
BUILTIN\Administrators:(special access:) READ_CONTROL SYNCHRONIZE FILE_GENERIC_READ FILE_READ_DATA FILE_READ_EA FILE_READ_ATTRIBUTESand I can't change it either. I do have the administrator privileges. For copying I didn't use any fancy tool, so I'd expect me to be the owner of the copy. Why can't I delete it? Do I need to boot Linux?
03 Answers
Open a Command Prompt window and leave it open. Close all open programs. Click Start, Run and enter TASKMGR.EXE Go to the Processes tab and End Process on Explorer.exe. Leave Task Manager open. Go back to the Command Prompt window and change to the directory the AVI (or other undeletable file) is located in. At the command prompt type DEL where is the full path to the file you wish to delete. Go back to Task Manager, click File, New Task and enter EXPLORER.EXE to restart the GUI shell. Close Task Manager.
3you could try displaying who the owner is (dir /q). Also try logging in as Administrator, and changing ownership to Administrator(google taking ownership). Can you then still not set Everyone to have write access?
you can also try Process Explorer, and see what process if any, is locking the file and end the process. Sometimes(I think in the case of svchost.exe) you can move the mouse over that process in process explorer and see a particular service and stop that and delete the file.
if you are desperate and give up doing it properly,
you could try a program called unlocker. Or a form of Win XP PE(a Win XP "Live CD" so to speak) like Bart's or UBCD.
7I've read a lot posting about this here and on elsewhere on the web. Conclusion: It's just hopeless. There may be a solutions for any particular case, but there are just too many cases:
- Filenames valid in NTFS but invalid in Windows
- Files lock by a running process
- Files lock by a process not running anymore
- Filenames with non-ASCII characters
- Filenames ending with spaces
- Strange ACL
- Strange owner
There was even somebody here who tried 4 answers in row, where each helped to remove some files.
Nevermore! Booting Linux from a CD or USB is the only way I'd ever recommend to anybody. It works always and the reboots take less time than the more fancy solutions I've seen.
3