Search code examples
iconsinno-setup

Possible to change the application file's icon with Inno Setup?


I'm using Inno Setup to create a Windows software installer, and would like to use a custom icon for the distributed exe file (which will be located in C > Program Files > MyProgram).

So far, I've been able to get the custom icon to work (sort of) for the desktop shortcut, by using the following code, placed under the [Icon] section...

Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
    IconFilename: "{app}\TheIcon.ico";  Tasks: desktopicon

When I say that it "sort of" worked... it did customize the desktop shortcut's icon, but the quality of the icon looks terrible compared to the quality of the original icon.

But the bigger issue is... I can't figure out how to customize the icon for the actual application (exe) file at all, or for the start menu shortcut.

I would have assumed that the following line would do the trick for the application file...

Name: "{pf}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
    IconFilename: "{app}\TheIcon.ico";

And I also assumed that the following code would do the trick for the start menu icon...

Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico";

But no dice. It just uses the default icon.

Can anyone tell what I'm doing wrong? I would post the entire script here but it seems that the Stack Overflow code editor doesn't like a bunch of curly brackets over multiple lines (if someone knows a way around that I'll be happy to post the whole script).

And FYI... for this particular project, changing the exe icon prior to running it through Inno Setup doesn't appear to be an option (I tried changing it via Resource Hacker, and although it succeeded in changing the exe's icon, it corrupted the file in the process, to where it wouldn't even run :(

If it's not possible to customize the application file's icon using Inno Setup, then do I have any other options?


Solution

  • As you know the application icon is built into the .exe file. The Inno Setup cannot modify the .exe files. And there's no other way to override the application icon by an external one.

    You have to edit the .exe file yourself, before building the installer.

    I personally use the Resource Hacker and have no problems with it.

    Make sure the license of the application you are modifying allows such customization.

    Also nowadays, executables need to be signed with certificate. And any modification, including changing of the icon, invalidates the signature. So you need to change the icon before signing the application.


    The icons in Windows Start menu are indeed set using IconFilename. I also have no problems with that.

    The problem might be that Windows caches the Start menu icons. So if you had that entry in Start menu before, reinstalling the application with new icons sometime won't make Windows reset the cache. It keeps displaying the old icons. Try to uninstall, restart, and reinstall.