22

I have created an installer with Inno Setup. The icon used for the desktop shortcut and start menu is embeded in the application executable.

When the installer was initially created, I didn't have the final product icon from the design team. I used a temporary icon instead as I completed the installer.

Everything worked as it should until I changed the icon for the final one. Now the desktop shortcut and start menu icons always display the old icon even though everywhere else the icon is correct.

This is the Icon declaration section of the script.

[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; WorkingDir: {app}
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}; IconFilename: {app}\Icons\stop.ico
Name: {commondesktop}\{#MyAppVersionName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon; WorkingDir: {app}

Here's what I've tried: (This is a Windows 7 system)

If I look at the shortcut properties, and choose "change icon" I see the correct icon. Re-selecting it has no effect. I've also tried selecting a dis-related icon and then re-selecting the correct on... still shows the old one.

I've followed suggestions to delete the IconCache.db and restarting the machine but this has no effect either.

Where in the world is the old icon coming from? It's nowhere in the installer.

Ideas anyone?

swirlywonder
  • 531
  • 1
  • 4
  • 11
  • 1
    The way your question is written leads me to believe that this is all occurring on one, single Windows 7 computer. Have you tried rebuilding the Inno Setup file with the new icon and running it on a *second* computer? Does this still show the old icon? – Cody Gray - on strike Dec 09 '10 at 16:21
  • 1
    I've installed this application on both a 'virgin' Windows XP and a Windows 7 machine. Both render the icon correctly. What could possibly be caching the old icon on my machine? It just refuses to die... – swirlywonder Dec 09 '10 at 16:58
  • Post the [Icons] section of your installer script, perhaps that will help. Does your executable only contain the icon you want to use (i.e. not the temporary icon you don't want)? – Bernard Dec 09 '10 at 17:14
  • 3
    Yeah, the problem isn't related to Inno Setup then, if the correct icons are shown after the install on two other machines. It has to be something on your machine, and there's a 96% chance it's related to caching. – Cody Gray - on strike Dec 09 '10 at 17:19
  • No the temporary icon no longer exists anywhere in the application or the installer. I have added the [Icons] declaration to the topic description. – swirlywonder Dec 09 '10 at 17:20
  • I would agree. It is caching on machines that have used the previous installer, but I'm at a loss as to where the caching is. – swirlywonder Dec 09 '10 at 17:22

3 Answers3

31

It seems that this indeed was related to the IconCache.db file. I can only guess that something wasn't done in the right order (though I tried differing procedures more than once).

Here's how I performed the reset manually:

  • Click Start button > Hold down Ctrl+Shift & Right Click on empty area in the Start Menu.
  • Select "Exit Explorer".
  • Hold Ctrl+Shift+Esc keys to open Task Manager.
  • Select "File" > "New Task".
  • Type: cmd (and press Enter). This will open the command prompt.
  • Type: cd /d %userprofile%\AppData\Local (and press Enter)
  • Type: attrib –h IconCache.db (and press Enter)
  • Type: del IconCache.db (and press Enter)
  • Type: start explorer (and press Enter)

Now everything renders just as it should.

Otiel
  • 18,404
  • 16
  • 78
  • 126
swirlywonder
  • 531
  • 1
  • 4
  • 11
  • 6
    It's a bug in Windows (Win7 and Vista too as I remember). The icon cache flat-out does not notice when the entire EXE has changed (not just the icon), even across reboots. Another screw-up is if you create the shortcut before the exe exists then the shell caches a generic icon and uses that forever more until you manually force the stupid thing to rebuild the cache. – Leo Davidson Dec 09 '10 at 19:11
  • That seems like a pretty bad bug... Especially to still be there across two major releases. – swirlywonder Dec 09 '10 at 19:29
  • 1
    @Leo: I think I agree with you because I've seen this before. Have you filed a bug report on this (or do you know of any that have been filed)? – Cody Gray - on strike Dec 10 '10 at 14:41
  • @Cody Gray: I gave up filing bug reports with Microsoft. Total waste of time, IMO. :\ – Leo Davidson Dec 10 '10 at 15:25
  • 1
    +1 thank you! i've already wasted enough time on this, you saved me wasting more time. i was uninstalling and reinstalling and the icons were not showing... – Joe Jun 27 '11 at 05:46
  • I had this problem with windows 7 too, thnx for the useful answer... :-) – ehsan0x Jul 24 '11 at 19:57
  • Bug stil exists on Windows 10, FWIW. – elder elder Oct 18 '18 at 00:37
11

As in swirlywonder's answer, this batch script should automate the process:

rebuild-icon-cache.bat

@echo off
taskkill /IM explorer.exe /F
cd /d %userprofile%\AppData\Local
del IconCache.db /a
start explorer.exe
MTCoster
  • 5,868
  • 3
  • 28
  • 49
0

There is a better way. Ship separate .ico file within your installer, and then use IconFilename parameter in [Icons] section to target that icon instead of the one in the exe.

Dejan Grujić
  • 402
  • 2
  • 6