1

Note that I am new to Inno Setup. Currently I have the following:

Installation language selection (1) -> Select additional tasks (2) -> Ready to install (3) -> Installing (4) -> Click finish to exit Setup. (5)

What I want to achieve is to have user prompted for Additional tasks (2) after Installing (4). I have Create a desktop shortcut and Launch application checkboxes on Additional tasks.

Here is the script that I use for generating a setup (with various things replaced with mock data as I cannot disclose them).

#define MyAppName "My App"
#define MyAppExeName "MyApp.exe"
#define MyAppVersion "1.0"
#define MyAppPublisher "MyCompanyName"

[Setup]
AppId={{someId}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=My App
SetupIconFile=C:\MyApp\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

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

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

[Files]
Source: "C:\Users\myuser\MyApp\bin\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

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

[Run]
Filename: {app}\{#MyAppExeName}; Flags: shellexec skipifsilent nowait; Tasks: StartAfterInstall

Update:

Changing my [Run] section to this:

Filename: {app}\{#MyAppExeName}; Flags: shellexec skipifsilent nowait; AfterInstall: CreateIcon

and adding the [Code] section as follows:

[Code]

procedure CreateIcon;
var
  IconFileName: string;
begin
  IconFileName := ExpandConstant('{commondesktop}\DashBoard.lnk');

  CreateShellLink(
    IconFileName, '',
    ExpandConstant('{app}\{#MyAppExeName}'),
    '', ExpandConstant('{app}'),
    ExpandContant('{app}\logo.ico'), 0, SW_SHOWNORMAL);
end;

did not add a checkbox to the last setup step.

I tried adding ChangesAssociations=yes to the end of my [Setup] section with no checkbox added either.

After that I thought I could use the same method as with which I've managed to add a checkbox to launch an application on the last setup step.

So, trying to add a second checkbox like this:

[Run]
Filename: {app}\{cm:AppName}.exe; Description: {cm:LaunchProgram,cm:AddShortcut,{cm:AppName}}; Flags: nowait postinstall skipifsilent

[CustomMessages]
AppName=MyApp
LaunchProgram=Start MyApp after finishing installation
AddShortcut=Add desktop shortcut

leaves me with only one checkbox instead of two.

Might I just say that before adding a second checkbox it was like so:

[Run]
Filename: {app}\{cm:AppName}.exe; Description: {cm:LaunchProgram,{cm:AppName}}; Flags: nowait postinstall skipifsilent

[CustomMessages]
AppName=MyApp
LaunchProgram=Start MyApp after finishing installation

If any further information is needed - let me know.

Update:

Here is latest version of script:

#define MyAppName "MyApp"
#define MyAppExeName "MyApp.exe"
#define MyAppVersion "1.0"
#define MyAppPublisher "MyCompany"

[Setup]
AppId={{678F2A68-E028-46F0-A18C-0A47135A98E8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=MyApp
SetupIconFile=C:\Users\myuser\Projects\MyApp\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

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

[Files]
Source: "C:\Users\myuser\Projects\MyApp\bin\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

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

[Run]
Filename: {app}\{cm:AppName}.exe; Description: {cm:LaunchProgram,{cm:AppName}}; Flags: postinstall skipifsilent;
Filename: {app}\{cm:AppName}.exe; Description: {cm:AddShortcut,{cm:AppName}}; Flags: postinstall skipifsilent;

[CustomMessages]
AppName=MyApp
LaunchProgram=Start MyApp after finishing installation
AddShortcut=Add shortcut to desktop

[Code]

procedure CreateIcon;
var
  IconFileName: string;
begin
  IconFileName := ExpandConstant('{commondesktop}\MyApp.lnk');

  CreateShellLink(
    IconFileName, '',
    ExpandConstant('{app}\{#MyAppExeName}'),
    '', ExpandConstant('{app}'),
    ExpandConstant('{app}\logo.ico'), 0, SW_SHOWNORMAL);
end;

Hope this helps.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

Optionally running an application after an installation has finished is easy. See:
Inno Setup - How to create checkboxes at finished page? or
Run application after successful install


Creating the desktop shortcut is more complicated. An easy way (from the perspective of Inno Setup script) is to "outsource" the shortcut creation – to the application itself (via a command-line parameter) or to some script (e.g. PowerShell). And then you can run that application/script the same was as the application above.

If you want the installer itself to create the shortcut, you would have to hack it like shown here:
Running script code (adding a registry key) instead of executable in Run entry in Inno Setup

A code to create a shortcut in code is here:
Create desktop link Icon after the Run section of Inno Setup

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992