Windows – Any way to delete corrupt NTFS files

windowswindows-server-2016

I've got myself into a situation on a Windows Server 2016 machines where I've somehow ended up with corrupt files in my %TEMP% directory (which on my system is in C:\users\username\appdata\local\Temp), as a result of some MDT activities that went bad. They are preventing some MDT functions from working properly.

When I try to delete a file as domain admin, it tells me I don't have permission. When I try to open the file, it says "the file cannot be accessed by the system". chkdsk says the file system is clean. I even tried booting into a boot CD, parted magic, and trying to delete the file from a browser there. I get an error there saying the file is corrupted. None of the disk checking tools I've tried have said there are any problems.

I'm almost at the point where I need to reinstall the OS, but thought I'd post here as a last-ditch effort.

Any help is greatly appreciated.

Best Answer

Try to use "takeown" command from cmd (elevated). For example: takeown /f C:\users\username\appdata\local\Temp /r

It will replace the owner of all dirs/subdirs and files recursively, so you must get access to clean up your temp folder