Jump to content
CCleaner Community Forums

CCleaner Under the Hood Related Question


Recommended Posts

I am curious how the developers of CCleaner have accomplished an aspect of their product.  How does CCleaner clean the thumbnail cache on Windows?  I'm writing something and part of it requires the thumbnail cache to be deleted.  Trouble is, depending on Windows settings, the cache is almost always locked/in use by the Explorer process.  I can not for the life of me figure out how to unlock these files to delete them.  I've tried the following:

Always set the "show icons, not thumbnails" setting via registry

- Close and restart explorer (I think this would work, but halts script--Python)

- Send a WM_CHANGESETTING message to all Windows

- Close all open handles to the files

Does CCleaner not delete the the in-use files?  Disk Cleanup deletes them too, so it must be able to be done.

Link to post
Share on other sites
  • Moderators

You probably need to run your script (or the program that runs the script) with administrator privileges if it's for instance Windows 10.

--------

As to what CCleaner does "under the hood," it's highly unlikely they'll give such details since it's closed source even though they offer a freeware version -- but that doesn't mean free software or open source software.

Link to post
Share on other sites
  • Moderators

It will probably depend what programming language you are writing your 'something' in. (I'm not familiar with Python).

Maybe your best bet would be to ask on a forum dedicated to Python?
Someone else may have figured it out.

The only way I have found to do it in a batch is to kill File Explorer, delete the Thumbnail cache, restart File Explorer and let it rebuild the cache.
You have to do the same and close FE if/when you want to rebuild the icon cache.

I've had similar problems trying to get the recycle bin icon to refresh without having to close FE and refreshing the whole icon cache.
You can refresh the bin icon when you empty the bin from a Powershell script. (but that then throws up a UAC warning so not what I want).

You can use the following in Powershell to remove the thumbnail db so that Windows will rebuild it (you'll need to be in an admin account).
Maybe you could call Powershell from Python?
PS. This won't work if you have an Explorer window open so that the db is in use, you'll get an error message.

Remove-Item "C:\" -include "thumbs.db" -recurse -force

 

Link to post
Share on other sites
3 hours ago, Andavari said:

You probably need to run your script (or the program that runs the script) with administrator privileges if it's for instance Windows 10.

--------

As to what CCleaner does "under the hood," it's highly unlikely they'll give such details since it's closed source even though they offer a freeware version -- but that doesn't mean free software or open source software.

I know it's closed source, but it doesn't hurt to ask.

2 hours ago, nukecad said:

It will probably depend what programming language you are writing your 'something' in. (I'm not familiar with Python).

Maybe your best bet would be to ask on a forum dedicated to Python?
Someone else may have figured it out.

The only way I have found to do it in a batch is to kill File Explorer, delete the Thumbnail cache, restart File Explorer and let it rebuild the cache.
You have to do the same and close FE if/when you want to rebuild the icon cache.

I've had similar problems trying to get the recycle bin icon to refresh without having to close FE and refreshing the whole icon cache.
You can refresh the bin icon when you empty the bin from a Powershell script. (but that then throws up a UAC warning so not what I want).

You can use the following in Powershell to remove the thumbnail db so that Windows will rebuild it (you'll need to be in an admin account).
Maybe you could call Powershell from Python?
PS. This won't work if you have an Explorer window open so that the db is in use, you'll get an error message.


Remove-Item "C:\" -include "thumbs.db" -recurse -force

 

That's similar to the way I found to do it too.  I've worked with the process more and more, and have managed to clear the cache, but it requires restarting Explorer.  At the time of my post, I hadn't figured it out.  CCleaner doesn't have to restart Explorer, so them fellers have figured something out.  Oh well, there's no harm I can think of from restarting Explorer. 

2 hours ago, hazelnut said:

Thanks for the link.

Link to post
Share on other sites
  • Moderators
18 hours ago, malonn said:

CCleaner doesn't have to restart Explorer, so them fellers have figured something out.

With Win10 I often see in Task Manager (near the bottom of the list) two instances of Explorer running and other times I don't. So maybe after I've just ran CCleaner it's closing one instance that isn't for what's seen on screen but is instead doing something else.

Another tool, BleachBit when deleting thumbnail cache it uses TaskKill ("C:\Windows\System32\taskkill.exe"), and on XP it's obvious it's restarting Explorer, I haven't tried to have it delete thumbnail cache on Win10 yet though since it's built into Windows Disk Cleanup.

Edited by Andavari
Re-wording, didn't make sense.
Link to post
Share on other sites

I looked at Bleachbit in my research and yeah, it restarts explorer.  I briefly looked at the source but didn't find the thumbcache related code.  I can live with restarting explorer to do what I want.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...