Quick and dirty way of cleaning the Windows icon cache

Posted by AB
Jun 17 2008

When developing my software, sometimes I need to try a few changes to the application icon, to see which image looks better. Unfortunately, replacing the icon within the application file does not make Windows recognize the new icon when displaying a shortcut to the file: it displays the old icon no matter what: pressing the F5 key to refresh the desktop, using the shortcut Properties window to force it to use the new icon, nothing has an effect.

The problem, of course, is the icon cache: turns out that Windows keeps each icon in its memory (the icon cache), and when it needs to draw the icon, it uses the copy from the cache rather than retrieving the icon image from the original application file. It makes Windows draw the icons faster, but the negative side effect is the inability of Windows to detect the change of the icon.

The naïve approach to this problem seems to be to delete the icon cache, and thus force Windows to recreate it from scratch. Browsing the user profile folder (such as C:\Users\Username on Vista, or C:\Documents and Settings\Username on XP) reveals the file named suspiciously IconCache.db (located in the subfolder AppData/Local on Vista or Local Settings\Application Data on XP. Note that this file usually has the SYSTEM and HIDDEN attributes, so you may need to change your Windows folder settings to see this file). However, deleting this file causes no effect: Windows keeps displaying the old icon. (Which is not very surprising, because the very fact that Windows did not stop us from deleting this file kind of tells us that the file was not in use by Windows). Even restarting the computer does not help: Windows simply recreates the IconCache.db file with the old icon in it, and keeps displaying the old icon!

Nevertheless, it is possible to delete the icon cache and force Windows to rebuild it. Turns out, Windows recreates the IconCache.db file when the user logs off from his or her account. When the user logs back on, Windows loads the IconCache.db file back intro its memory. This gives us the idea when could be the proper time to delete the IconCache.db file: when the user is logged off. But how to delete the file if the user is not logged on and there is no way to start Windows Explorer or some other file management tool (such as my AB Commander, sorry for the plug, couldn’t resist :-) ) Easy: log in to another user account (such as the administrator’s one) and delete the IconCache.db file that exists in your own profile (you do use separate accounts for the day-to-day work and for the administrative tasks, do you?) Another way is to log off from your account and then connect to your computer from another computer on your LAN (you do have both a desktop and a laptop, do you? And they can talk to each other over the local network, can they? If not, what are you doing reading this blog? Just kidding…) Anyway, from another networked computer navigate to your profile over the network, delete IconCache.db, then go back to the first computer and log back into your account. This time Windows will recreate its cache and start displaying the new icon.

P.S. There is a couple of other methods of forcing Windows to rebuild the icon cache. For example, in Vista, you can change the size of the desktop icons (by right-clicking on the desktop and using the View menu), and then change it back. Or, if you have Windows XP, open the Display Properties window from Control Panel, select the Appearance tab, and click on Effect. Now change the Use large icons option, click OK, Apply to have it take effect. Then repeat the procedure to change the option back to what it was before.

The advantage of these methods is that you don’t need to log off from your account to rebuild the icon cache. The disadvantage is that Windows may mess up the layout of your icons on the desktop, and you may need to rearrange them after the icon cache is updated.

Be Sociable, Share!

2 Responses

  1. betatester says:

    an easier way is to use this small utility called refreshiconcache.exe availabe there http://www.p2pforum.it/forum/attachment.php?attachmentid=6471&d=1142361850

    i’ve had it for many years, i don’t know its’ author and it doesn’t have a gui(about) or file version propertysheet to find out.. anyway it does the job, however i never had that problem when changing icons into binaries.. usually an F5 will suffice, but i do use it when i change icons for registered file types..those don’t refresh unless i use that tool.

    it works flawlessly on xpee.. i suppose it should work on vista

  2. AB says:

    Sorry, even with your assurance, there is no way I’m running an arbitrary executable without digital signature or even version information in it.

    Anyone reading this: if you decide to download and use the tool mentioned in the previous comment, please remember that I have nothing to do with it, and I don’t take any responsibility for it.

    Generally, there sure are tools that would do that (including PowerToys from Microsoft, if I remember correctly). What I’ve described is a method of achieving the result without any such tool.

IMPORTANT! Do not put any URLs in the comment, or it will be rejected. Before submitting, please solve the following simple math problem (so we know that you are not a spambot) :-)

What is 6 - 4 ?
Please leave these fields as-is: