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.