I'm trying to delete the thumbnail cache via the following command:

DEL /F /S /Q /A %LocalAppData%\Microsoft\Windows\Explorer\thumbcache_*.db

I execute the statement as administrator and before of that I end the explorer.exe.

But I always get an access denied error.

What can I do about that? It's Windows 10.


Use cleanmgr.exe also Elevated. Either via the GUI or with /sageset /sagerun options. This may be automated via registry settings and a batch/script. I just yesterday posted one

Here's a reduced version of the PowerShell script

#Requires -RunAsAdministrator
$SageSet = "StateFlags0099"
$Base = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\"
$Locations= @(
    "Thumbnail Cache"
ForEach($Location in $Locations) {
    Set-ItemProperty -Path $($Base+$Location) -Name $SageSet -Type DWORD -Value 2 -ea silentlycontinue | Out-Null
# do the cleanup . have to convert the SageSet number
$Args = "/sagerun:$([string]([int]$SageSet.Substring($SageSet.Length-4)))"
Start-Process -Wait "$env:SystemRoot\System32\cleanmgr.exe" -ArgumentList $Args -WindowStyle Hidden
# Removw the Stateflags
ForEach($Location in $Locations)
    Remove-ItemProperty -Path $($Base+$Location) -Name $SageSet -Force -ea silentlycontinue | Out-Null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.