Force Vista/Win7 to Rebuild Icons

Windows Vista and Windows 7 Icons:

In 9x/2k/XP, if icons got corrupted, you could rebuild them with TweakUI.

Microsoft hasn’t released TweakUI for Vista or Windows 7, so how do you trigger an icon rebuild?

I found that if you delete the icon cache, then change the color mode, Windows Vista and Win7 will rebuild your icons.

My provider recently forced me to remove a program to rebuild icons, as their malware scanners kept picking up the system changes as a trojan. :(

To try to get around that, here's a batch file you can make (should work on Vista and Windows 7).

@echo off
echo.
echo This will attempt to reset your icon cache and force Windows
echo to rebuild icons fresh.
echo.
echo You will need to change your color depth or restart your
echo computer after this is finished.
echo.
pause
echo.
echo Attempting to un-hide, delete, and reset icon cache...
echo.
attrib -a -r -h -s %LocalAppData%\IconCache.db
del /a %LocalAppData%\IconCache.db
type NUL > %LocalAppData%\IconCache.db
attrib +r +h %LocalAppData%\IconCache.db
echo Done!
echo.
echo Be sure to change your color depth (to 16-bit color and back)
echo or restart your computer to cause icons to finish rebuilding.
pause

These are the most important parts, as you can type them on a command line without putting them in a batch file:


attrib -a -r -h -s %LocalAppData%\IconCache.db
del /a %LocalAppData%\IconCache.db
type NUL > %LocalAppData%\IconCache.db
attrib +r +h %LocalAppData%\IconCache.db

The commands do the following:
- Unhides and makes the icon cache writable.
- Deletes the icon cache.
- Creates a new, blank icon cache.
- Makes the icon cache read-only, preventing Windows from writing bad data to it again.


Manual fixes:

Previous versions of Windows had a feature in "TweakUI" to rebuild the icon cache. Since Vista doesn't have TweakUI, you need to find other ways to rebuild the icon cache.

Make sure you have Command Prompt and Task Manager open.

Go to your local settings folder, such as:

C:\Users\YourName\AppData\Local>

Type “attrib -h iconcache.db” (without quotes)

Use Task Manager to kill Explorer.exe

Delete the IconCache.db file.

Type “explorer” to re-load Explorer.

Windows should re-build the icon cache.


Another method:

Delete the IconCache.db file as mentioned above, but instead of killing Explorer, instead switch to 16-bit color mode, and then back to 32-bit color mode.