Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a desktop icon with Inno Setup

I am very new of Inno Setup and I wish to add a Desktop icon to my executable in Inno Setup. The file is stored in

C:\Users\PycharmProjects\GIOTTOconverter\dist\giotto.ico

I tried to follow several examples but without results.

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

#define MyAppName "GIOTTO"
#define MyAppVersion "1.0"
#define MyAppExeName "GIOTTO.exe"

[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={{48A8A469-1711-46FD-AC87-1596EF57C123}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=GiottoSetup
SetupIconFile=C:\Users\PycharmProjects\GIOTTOconverter\dist\giotto.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "C:\Users\PycharmProjects\GIOTTOconverter\dist\GIOTTO.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\PycharmProjects\GIOTTOconverter\dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
like image 469
Gianni Spear Avatar asked Aug 28 '15 02:08

Gianni Spear


People also ask

How do I create a desktop shortcut for Inno?

In [Files] section, you install your giotto. ico to the application folder (you may want to install the icon only when the desktopicon task is selected). In [Icons] section, you create the desktop icon using the installed giotto. ico (when the desktopicon task is selected).

How do I change the icon on my Inno?

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.

How do I Setup an Inno Setup?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.

What language is Inno Setup?

It defines two languages: English, based on the standard Default. isl file, and Dutch, based on a third-party translation.


1 Answers

In [Files] section, you install your giotto.ico to the application folder (you may want to install the icon only when the desktopicon task is selected).

In [Icons] section, you create the desktop icon using the installed giotto.ico (when the desktopicon task is selected).

#define SourcePath "C:\Users\PycharmProjects\GIOTTOconverter\dist"
#define MyAppName "GIOTTO"
#define MyAppExeName "GIOTTO.exe"
#define MyAppIcoName "giotto.ico"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; \
    GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#SourcePath}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#SourcePath}\{#MyAppIcoName}"; DestDir: "{app}"

[Icons]
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
    IconFilename: "{app}\{#MyAppIcoName}"; Tasks: desktopicon

Though if the executable file (GIOTTO.exe) has the same icon linked into, you do not need to install the icon separately. Just use the icon from the EXE file:

#define SourcePath "C:\Users\PycharmProjects\GIOTTOconverter\dist"
#define MyAppName "GIOTTO"
#define MyAppExeName "GIOTTO.exe"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; \
    GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#SourcePath}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
    Tasks: desktopicon
like image 93
Martin Prikryl Avatar answered Oct 05 '22 23:10

Martin Prikryl