-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.iss
More file actions
130 lines (116 loc) · 4.75 KB
/
Copy pathinstaller.iss
File metadata and controls
130 lines (116 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
; AirCube Tray Inno Setup Script
; Creates a Windows installer for the AirCube system-tray app.
;
; LICENSE and README live one level up (AirCube/), so those paths use ..\.
; Build the .exe first via build_tray.py (or build_installer.py which does both).
#define MyAppName "AirCube Tray"
#define MyAppShortName "AirCubeTray"
#define MyAppVersion "2.0.2"
#define MyAppPublisher "StuckAtPrototype"
#define MyAppURL "https://github.com/stuckatprototype/aircubetray"
#define MyAppExeName "AirCubeTray.exe"
[Setup]
AppId={{A3D4E5F6-7890-4B2C-9D1E-3F5A7B9C1D2E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppShortName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=LICENSE
OutputDir=installer_output
OutputBaseFilename=AirCubeTray_Setup_v{#MyAppVersion}
Compression=lzma
SolidCompression=yes
WizardStyle=modern
PrivilegesRequired=admin
; Let the user opt into a per-user install (no UAC prompt, installs into
; %LocalAppData%). Matters because we write to HKCU\Run and {userstartup};
; under a per-user install those correctly map to the actual user's profile.
PrivilegesRequiredOverridesAllowed=dialog
; Intentional: the tray app is per-user (HKCU\Run + {userstartup} shortcut).
; When installing for all users, those entries apply to the installing user's
; profile only, which matches how this app is expected to be used.
UsedUserAreasWarning=no
SetupIconFile=aircube_tray.ico
UninstallDisplayIcon={app}\{#MyAppExeName}
UninstallDisplayName={#MyAppName}
VersionInfoVersion={#MyAppVersion}
VersionInfoCompany={#MyAppPublisher}
VersionInfoDescription={#MyAppName} Setup
VersionInfoProductName={#MyAppName}
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "startup"; Description: "Launch {#MyAppName} at Windows startup"; GroupDescription: "Startup Options:"
[Files]
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "README.md"; DestDir: "{app}"; Flags: ignoreversion
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: startup
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[UninstallRun]
; Stop the tray app (graceful then force) before files are removed.
Filename: "taskkill"; Parameters: "/IM {#MyAppExeName}"; Flags: runhidden; RunOnceId: "StopAirCubeTray"
Filename: "taskkill"; Parameters: "/F /IM {#MyAppExeName}"; Flags: runhidden; RunOnceId: "KillAirCubeTray"
[UninstallDelete]
; Clean up any empty install folder left behind.
Type: dirifempty; Name: "{app}"
[Registry]
; The app's Settings dialog can register itself in HKCU Run under the name
; "AirCubeTray". Remove that key on uninstall so we don't leave a dangling
; entry pointing at a deleted .exe.
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: none; ValueName: "AirCubeTray"; Flags: deletevalue uninsdeletevalue
[Code]
function AppIsRunning(): Boolean;
var
ResultCode: Integer;
begin
// `find` exits 0 only when the image name appears in the tasklist output.
Result := Exec('cmd.exe',
'/c tasklist /FI "IMAGENAME eq {#MyAppExeName}" /NH | find /I "{#MyAppExeName}" > nul',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0);
end;
procedure CloseRunningApp();
var
ResultCode: Integer;
begin
Exec('taskkill', '/IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(500);
Exec('taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(1000);
end;
function InitializeSetup(): Boolean;
begin
Result := True;
if AppIsRunning() then
begin
if WizardSilent() or
(MsgBox('{#MyAppName} is running. Close it now and continue with the installation?',
mbConfirmation, MB_YESNO) = IDYES) then
CloseRunningApp()
else
Result := False;
end;
end;
function InitializeUninstall(): Boolean;
var
ResultCode: Integer;
begin
Result := True;
// Try graceful close, then force kill so the .exe is no longer locked.
Exec('taskkill', '/IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(500);
Exec('taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Sleep(1000);
end;