How to bring the .ico file to the desktop shortcut?

1,664 views
Skip to first unread message

Ruediger

unread,
Oct 10, 2022, 2:45:12 PM10/10/22
to innosetup
Hi, I've trouble to create a setup using Inno Setup 6.2.1, because I don't know how to bring the .ico file to the desktop shortcut. If I try to use IconFilename, IconFilename isn't recognized. How to change the command lines to bring the .ico file to the desktop shortcut? Thanks!


; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "XXX"
#define MyAppVersion "1.0"
#define MyAppExeName "XXX.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".exe"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{6653A083-8F4B-4C4B-ADEE-E9DA86C1B5F8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DisableProgramGroupPage=yes
LicenseFile=C:\Users\Win10\Desktop\MNO\License.rtf
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\Win10\Desktop\MNO
OutputBaseFilename=Setup XXX
SetupIconFile=C:\Users\Win10\Desktop\MNO\music.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "DesktopIcon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"

[Files]
Source: "C:\Users\Win10\Desktop\MNO\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" ; Tasks: desktopicon ; WorkingDir: "{app}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"  ; Tasks: desktopicon ; WorkingDir: "{app}"


[Run]                                                                                                    
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent ; Tasks: desktopicon

Gavin Lambert

unread,
Oct 10, 2022, 5:56:47 PM10/10/22
to inno...@googlegroups.com
On 11/10/2022 07:45, 'Ruediger' wrote:
> Hi, I've trouble to create a setup using Inno Setup 6.2.1, because I
> don't know how to bring the .ico file to the desktop shortcut. If I try
> to use IconFilename, IconFilename isn't recognized. How to change the
> command lines to bring the .ico file to the desktop shortcut? Thanks!

The preferred method for exe files is to embed your icon as the first
resource in the exe itself; that way it will automatically get the icon
without any IconFilename required. This will also automatically work
for any custom shortcuts the user makes directly from the exe file.

But if you still want to use an IconFilename, you just need to install
it somewhere (typically {app} or a subfolder) with a [Files] entry, then
use its {app}\whatever path in the IconFilename.

Rüdiger Beer

unread,
Oct 11, 2022, 3:32:36 AM10/11/22
to inno...@googlegroups.com

Thanks for your explanations. But unfortunately I cannot proceed, because the only thing what I understand in that code lines is, that #... are constants. I just don't know that way of coding. So I can try out what I want, it will cause errors ever.

What means {app} for example? As already told above, I don't know that programming style. Inno Setup embeds the .ico file automatically to the setup itself, to the uninstaller and so on, but only the most important place, namely the desktop shortcut isn't considered.


I've tried out a tool to embed an .ico file directly into my .exe file, but the .exe file didn't work then anymore. What tool can you suggest to embed .ico into .exe? 


Or I just get some suitable code lines here in this forum to my given command lines. Would be biggest appreciated, Thanks!



10. Okt. 2022, 23:56 von i...@mirality.co.nz:
On 11/10/2022 07:45, 'Ruediger' wrote:
Hi, I've trouble to create a setup using Inno Setup 6.2.1, because I don't know how to bring the .ico file to the desktop shortcut. If I try to use IconFilename, IconFilename isn't recognized. How to change the command lines to bring the .ico file to the desktop shortcut? Thanks!

The preferred method for exe files is to embed your icon as the first resource in the exe itself; that way it will automatically get the icon without any IconFilename required. This will also automatically work for any custom shortcuts the user makes directly from the exe file.

But if you still want to use an IconFilename, you just need to install it somewhere (typically {app} or a subfolder) with a [Files] entry, then use its {app}\whatever path in the IconFilename.

--
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.

Eivind Bakkestuen

unread,
Oct 11, 2022, 7:24:50 AM10/11/22
to inno...@googlegroups.com
Do yourself a favour and read some documentation, and look at the examples provided with Inno Setup.


Embedding an .ico file into an executable is usually done with the development tool that creates the exe. Sorry, I don't have a link to a working resource editor.



You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/NE4xORk--3-2%40tutanota.de.

Rüdiger Beer

unread,
Oct 11, 2022, 4:11:08 PM10/11/22
to inno...@googlegroups.com

Thanks, but unfortunately the tips didn't help me at all. I struggled for hours to get a desktop icon created. It worked then indeed, but my exe file didn't launch then.

What do you mean with "embedding an .ico file into an executable"? 


Pathetic manuals are of no use for me to gain knowledge, so there are three possibilities for me now: Either I accept the Windows default icon or I find someone to pay for probably 3 lines of code or I get the help I want here in this forum. Inno Setup is good so far, but to get a desktop icon created is reserved to experts only. If Inno Setup would have been made differently from the start, I wouldn't need to ask for help here. Thanks again.


Otomatic

unread,
Oct 12, 2022, 3:17:27 AM10/12/22
to innosetup
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\favicon.ico"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"; IconFilename: "{app}\favicon.ico"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; IconFilename: "{app}\favicon.ico"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\favicon.ico"
Message has been deleted
Message has been deleted

Rüdiger Beer

unread,
Oct 12, 2022, 6:06:46 PM10/12/22
to innosetup
Thank you very much for your code lines. After having some trouble again I could achieve to get the icon file connected to the desktop shortcut. To place the .ico file under source: was also a good idea. But one disadvantage is still left, because the .ico file is also stored in the programs(x86) folder now. If there is a possibility to avoid that I would be glad to get the info how to do that. Thanks.

Eivind Bakkestuen

unread,
Oct 13, 2022, 12:50:52 AM10/13/22
to inno...@googlegroups.com
Look at the doc link I gave you before, and look for constants that lets you use the common document folder or similar?

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.

Rüdiger Beer

unread,
Oct 13, 2022, 9:59:49 AM10/13/22
to innosetup
I had opened the link immediately, thanks. But the content which appears then is only of use to those who already know how to use it. After taking another careful look at the code I see nothing that would indicate that the .ico file is placed in the program folder(86). I hereby request an explanation of how I can prevent this from happening. Otherwise, I'm glad to have even managed to get the icon to appear on the desktop shortcut. 

Eivind Bakkestuen

unread,
Oct 14, 2022, 5:25:19 AM10/14/22
to inno...@googlegroups.com
If you look at your script lines, you will see {...} Constants. Read the docs at the link and apply info regarding the specific constants. 

Message has been deleted
Message has been deleted

Rüdiger Beer

unread,
Oct 14, 2022, 7:37:12 PM10/14/22
to innosetup
The unwanted effect was triggered by the later added source line, because there was DestDir: "{app}". I replaced this with "{src}" (also in the corresponding places in the code) and then indeed the .ico file disappeared from the program folder (x86). Why the usual method with Task: desktopicon didn't work for me, I don't know. But anyway, the goal is now achieved. Thanks again for your help and sorry that I was not quite satisfied in the meantime.

Eivind Bakkestuen

unread,
Oct 14, 2022, 7:44:44 PM10/14/22
to inno...@googlegroups.com
Docs: "{src} The directory in which the Setup files are located."

Your user could run the installer from a USB stick. When they remove the stick, your icon won't be found.

Rüdiger Beer

unread,
Oct 14, 2022, 8:01:29 PM10/14/22
to innosetup
Thank you very much for this important hint! In other words, do I have to rely on "{app}" again or is there another way out? From the docs it's just not clear enough to me. If necessary I could also live with the .ico file in the program folder(x86) if I can then be sure that the Installer will run properly also on customer computers, but it would be nicer without that entry. Thanks.

Eivind Bakkestuen

unread,
Oct 15, 2022, 12:26:10 AM10/15/22
to inno...@googlegroups.com
It has already been said above. *read the doc page* on the different constants that are available. If you don't want "program files", then usually something like the common application data folder {commonappdata} would work. And you would want to follow some folder convention like  {commonappdata}\your_company_name\your_app_name

The only way to make sure it all works, is to set up a separate test environment. Make yourself an "end user" virtual machine, take a snapshot before you install anything, and test as much as you can.


Rüdiger Beer

unread,
Oct 15, 2022, 8:47:22 AM10/15/22
to innosetup
I'm now using {commonappdata} and that works very well, even on other laptops. Many thanks again!
Reply all
Reply to author
Forward
0 new messages