Tuesday, 3 March 2009

Undeletable files in Vista: solution

A couple of times I've had files on my Vista PC that can't be deleted, and the usual trick with a batch file containing:

takeown /f %1 /r /d y
icacls %1 /grant administrators:F /t

doesn't work ("Access denied").

It turns out that it was due to an explorer.exe process having the files open. The "handle" utility from the Sysinternals toolbox revealed which process had the file open. I killed that process (the taskbar disappeared as a result, so I opened the task manager and used File->Run... to start another explorer.exe, and the taskbar returns). The stubborn file could then be deleted...

No comments: