28

I have got this file that I can't delete. It happened after a system crash, so the CHKDSK kicked in upon next reboot. After that, I can't delete the file. This is on Windows Home Server, and the file is one of those hidden Thumbs.db, and my Windows Home Server reports a "File conflict" on the file, the reason: "Access Denied"

What I have tried so far, running as an Administrator:
Delete: Access Denied
TakeOwn.exe : Access Denied
Attrib.exe -s -h : Access Denied
cacls.exe : Access Denied (even whe trying to display the current owner)
Rename: File not found (its hidden)
Re-boot in to safe mode and tried the above: Access Denied
Running the above commands as Local System: Access Denied

Tizer Unlocker: Fail (Doesn't find anything locking the file)
File Assasin: Crashes ("FindRemoteFileHandles returned NULL value.")

I have used the CHKDSK /f again, rebooted since some suggestions is that the file has been corrupted, but that didn't change anything.
Any suggestions ?

Update: In a totally different scenario, I experienced a similar situation; Access Denied when trying to take ownership of a file. It turned out that the file was owned by TrustedInstaller, which is not possible to override just by being an Administrator. In this case, one can use psexec /ids cmd to elevate yourself to System and then TakeOwn.exe /a

Henke
  • 1,261
Magnus
  • 1,078

5 Answers5

24

[Update 2022] Please note that, as @Henke noticed in the comments below, apparently Unlocker is being flagged as unsafe by a bunch of antivirus engines. Not sure if it's the bundled adware or something more malicious, but perhaps it would be best to try the LockHunter tool that is recommended in this related thread.

So a big disclaimer, since most likely the steps outlined in the other thread will do the trick, please use at your own risk as a last resort only.


I had the same problem earlier today and fixed it using Unlocker. I don't know if it's any different from the tool that Nicu Zecheru recommmended, but I thought I'd share it here for future reference.

At first didn't believe that the folder could actually be locked, I restarted my PC several times since I first discovered that I am unable to access it, and none of these things worked:

  • chkdsk /f - scanned the disk but found nothing
  • takeown - access denied
  • fileacl /force - access denied
  • cacls.exe, xcacls.exe - no luck

Unlocker found that Windows Media Player was locking the file. If I remember correctly, I did have a video file in that folder, but I don't think I ever tried to open it using WMP. I copied the folder from a network location initially, and it's possible WMP might have accessed it during its background library crawling.

NOTE: it seems that older versions of Unlocker were bundled with adware (nothing nasty thought, some e-bay shortcuts from what I've seen). I simply unchecked these items during installation and everything was smooth.

vgru
  • 1,166
5

I can't get any higher in the hierarchy than Administrator

Sure you can. The local System account has higher privileges than Administrator. To start a command prompt under the System account, issue the command

at (time) /interactive cmd.exe

Where (time) is the current time plus 1 minute. Alternatively, download Sysinternals' PSTools and use

psexec -i -s cmd.exe

The elevated command prompt will start in a different directory from usual, which for me is

C:\WINDOWS\system32>
Hugh Allen
  • 10,120
2

I cam across a similar situation where I had a file like this where every command would fail with some type of access denied message even when I should have had adequate rights to access it.

In my case, it turned out that it had actually had been deleted and there is a way on a Windows NTFS file system that it can go into a STATUS_DELETE_PENDING state that most tools will detect as "Access Denied" Stackoverflow - Why does Windows return Error Access Denied when I try to Open a Delete Pending File.

This situation is very frustrating and difficult to diagnose with existing tools (I had to use Sysinternals Procmon and scan through lines of logs), so I made my own tool to detect this condition as well as other file opening problems. Hopefully it will be useful for someone. Github - Detect-ghost-file

bruceceng
  • 141
1

You can try using Tizer Unlocker (freeware)

Here are some of the error messages that can be dealt with Tizer:

The file is in use by another program or user. Cannot delete file: It is being used by another person or program. Cannot delete folder: It is being used by another person or program. Cannot delete file: Access denied. The source or destination file may be in use. The process cannot access the file because it is being used by another process. There has been a sharing violation. Close any programs that might be using the file and try again. Make sure the disk is not full or write-protected and that the file is not currently in use. Error deleting file or folder. Cannot delete file or folder: The file name you specified is not valid or too long. Specify a different file name.

Nicu Zecheru
  • 5,572
-1

A caution: If the file is in the Windows directory or somewhere sensible, be careful about deleting it.

First, try booting in Safe mode to delete the file.

Second, sometimes the file is locked by explorer.exe itself. To solve such a problem:

  1. In Safe mode, launch a Command Prompt (cmd) as administrator
  2. Navigate in cmd to the directory in question and enter (but do not execute) a "del" command for the file in question
  3. Use Task Manager to kill explorer.exe
  4. Quickly press Enter in the cmd window to delete the file, before Windows restarts explorer

Third, the free utilities MoveOnBoot or Unlocker can be used to schedule delete of the file at boot time.

harrymc
  • 498,455