Wrong desktop shortcut icon on Windows 7 (Inno Setup)

混江龙づ霸主 提交于 2020-01-09 12:54:52

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/4400472/wrong-desktop-shortcut-icon-on-windows-7-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!