How to create a desktop shortcut icon with Inno Setup

Written by Radu Popescu · August 22nd, 2024 · 5min read

In this blog article, I’ll show you how to create a desktop shortcut icon for your main executable using Inno Setup.

Creating a Desktop Icon with Inno Setup

Inno Setup is a script-based tool for creating installers. While it lacks a full graphical interface, it includes a Script Wizard that helps you generate scripts with basic entries, including the creation of a desktop shortcut.

Let’s walk through the steps to create a desktop shortcut for a 64-bit application named InnoIconDemo.

The main executable “myappexecutable.exe” will be installed under “C:\Program Files\InnoIconDemo”, and the shortcut icon will be extracted from the executable.

1. Open Inno Setup Compiler and select New File -> Create a new script using Inno Setup Script Wizard.

Create script with Inno Setup

2. Enter application information.

Inno Setup Script Wizard

3. Specify the installation directory as C:\Program Files\InnoIconDemo.

Application Folder in Inno Wizard

4. Browse for the main application executable.

Browse the application exe in Inno Setup

5. Here, since we don’t have any file association, we leave everything unchecked.

Application File Association Wizard

6. In the script wizard, select the option to create a desktop shortcut. You can also choose to create a shortcut in the Start Menu.

Create shortcut in Start Menu with Inno Setup

7. Proceed through the remaining steps of the wizard as shown below.

Application Documentation in Inno Wizard
Install Mode selection in Inno Setup
Application Registry Keys in Inno Setup
Select Setup Language in Inno Setup
Compiler Settings in Inno Setup
Use #define compiler directives in Inno Setup

At the end of this process, the wizard generates the following code:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "InnoIconDemo"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"
#define MyAppExeName "myappexecutable.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={{46321D72-0520-4673-BB85-1A7EAFE90376}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "D:\Ai_Workspace\Sample apps\InnoIconDemo\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

Add Desktop Shortcut to an Existing Application

If you have an existing application and only want to add a desktop shortcut, simply add the Tasks and Icons sections as shown below.

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

Explanation of the [Tasks] Section

Parameters:

  • Name: The internal name of the task, used to reference the task in other sections like [Icons].
  • Description: The text that appears in the installer for the task. {cm:CreateDesktopIcon} is a built-in message constant that translates to "Create a &desktop icon".
  • GroupDescription: Groups related tasks in the installer UI. {cm:AdditionalIcons} translates to "Additional icons:".
  • Flags: These are additional options that modify the behavior of the task.

Common Flags:

  • unchecked: The task is unchecked by default, so no desktop shortcut is placed unless the user selects the option during the install wizard.
  • exclusive: Ensures that only one task within the same group can be selected at a time.
  • checkedonce: The task will be checked the first time the installer runs but not on subsequent runs. This means the desktop icon will be placed by default unless the user unchecks the option during the installation.
  • restart: The installer prompts the user to restart the computer at the end of the installation process.
  • exclusivegroupname: Create mutually exclusive groups of tasks. Only one task within the same group can be selected.

Compiling and Testing

Compile the installer and run it. During the installation, you'll see the option to create a desktop shortcut.

Create desktop shortcut option in Inno Setup

After completing the setup, the shortcut should appear on the desktop.

Shortcut icon on Desktop

Creating a Desktop Shortcut with Advanced Installer

Advanced Installer offers a more intuitive GUI for creating a desktop shortcut.

Here’s how:

1. Under Files and Folders, locate your main executable file.

2. Go to the Shortcuts section on the left pane, right-click on the right pane, and choose Installed File.

Shortcuts section in Advanced Installer

3. Browse for the main executable file.

Browse the executable file in Advanced Installer

4. Navigate to the Paths section and click the three dots to select the Shortcut folder.

Shortcut folder in Path section

5. Modify to Desktop shortcut and click OK.

Select Desktop as Installation Folder

6. Check the Desktop folder under Files and Folders to see the newly created shortcut.

Check Desktop under Files and Folders section

Video Tutorial

Conclusion

Creating a desktop shortcut with Inno Setup is straightforward, but if you’re looking for an even simpler and more efficient approach, Advanced Installer provides an intuitive, GUI-based solution that makes the process seamless.

See how Advanced Installer can work for you—enjoy a 30-day full-feature trial.

Written by
See author's page
Radu Popescu

Technical Writer at Advanced Installer, Technical Engineer on various enterprise client projects. Experienced in Software Packaging, SCCM infrastructure and System Administrating. Tech enthusiast and music producer in his spare time.

Comments: