-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinstaller.iss
More file actions
85 lines (73 loc) · 3.76 KB
/
Copy pathinstaller.iss
File metadata and controls
85 lines (73 loc) · 3.76 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
; Heavily inspired by Ollama: https://github.com/ollama/ollama/blob/main/app/ollama.iss
#define MyAppExeName "headset-battery-indicator.exe"
#define MyAppDebugExeName "headset-battery-indicator-debug.exe"
#define MyAppDisplayName "Headset Battery Indicator"
[Setup]
AppId=88ECD258-57B9-4DDB-ABA3-67DC0289A92C
AppName={#MyAppDisplayName}
; keep this up to date
AppVersion=3.6.0
WizardStyle=modern
DefaultDirName={localappdata}\Programs\HeadsetBatteryIndicator
DefaultGroupName={#MyAppDisplayName}
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
; Since no icons will be created in "{group}", we don't need the wizard
; to ask for a Start Menu folder name:
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\{#MyAppExeName}
SetupIconFile=src/icons/main.ico
Compression=lzma2
SolidCompression=yes
OutputBaseFilename="HeadsetBatteryIndicatorSetup"
PrivilegesRequired=lowest
CloseApplications=force
RestartApplications=no
DirExistsWarning=no
SetupMutex=Headset-Indicator-Mutex
[Files]
Source: "target/release/headset-battery-indicator.exe"; DestDir: "{app}"; Flags:
Source: "target/release/headset-battery-indicator-debug.exe"; DestDir: "{app}"; Flags:
Source: "licenses/HeadsetControl.txt"; DestDir: "{app}/licenses"; Flags: ignoreversion
[Icons]
Name: "{userstartup}\Headset Battery Indicator"; Filename: "{app}\headset-battery-indicator.exe";
Name: "{autoprograms}\Headset Battery Indicator"; Filename: "{app}\headset-battery-indicator.exe";
[Run]
Filename: "{app}\headset-battery-indicator.exe"; WorkingDir: "{app}"; Description: "Launch application (it will show up inside the task bar ^-arrow menu)"; Flags: postinstall nowait
[InstallDelete]
Type: filesandordirs; Name: "{%LOCALAPPDATA}\ArctisBatteryIndicator"
Type: filesandordirs; Name: "{%LOCALAPPDATA}\Programs\HeadsetBatteryIndicator"
Type: filesandordirs; Name: "{%LOCALAPPDATA}\Programs\ArctisBatteryIndicator"
Type: filesandordirs; Name: "{userstartup}\headset-battery-indicator.lnk"
Type: filesandordirs; Name: "{userstartup}\arctis-battery-indicator.lnk"
[UninstallRun]
Filename: "taskkill"; Parameters: "/im ""headset-battery-indicator.exe"" /f /t"; Flags: runhidden; RunOnceId: "Kill exe"
Filename: "taskkill"; Parameters: "/im ""headset-battery-indicator-debug.exe"" /f /t"; Flags: runhidden; RunOnceId: "Kill exe (debug)"
Filename: "taskkill"; Parameters: "/im ""arctis-battery-indicator.exe"" /f /t"; Flags: runhidden; RunOnceId: "Kill exe (debug)"
Filename: "taskkill"; Parameters: "/im ""arctis-battery-indicator-debug.exe"" /f /t"; Flags: runhidden; RunOnceId: "Kill exe (debug)"
; HACK! need to give the server and app enough time to exit
Filename: "{cmd}"; Parameters: "/c timeout 1"; Flags: runhidden; RunOnceId: "Wait"
[UninstallDelete]
Type: files; Name: "{app}\headset-battery-indicator.log"
Type: dirifempty; Name: "{app}"
[Code]
function KillProcessByName(ProcessName: string): Boolean;
var
ResultCode: Integer;
begin
// Attempt to kill a process by name using taskkill
Result := Exec('taskkill.exe', '/F /IM "' + ProcessName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
// Runs after the user has pressed "install"
// Why is it necessary to kill the previous process with taskkill instead of relying on
// the Windows restart manager that Inno Setup normally uses?
//
// The tray-icon crate creates a new window via the win32 api, but actually doesn't
// provide a way to react to the events sent by restart manager (WM_QUERYSESSIONEND, WM_CLOSE)
// this means that there's currently no way to gracefully close the program, so we have to manually kill it.
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
KillProcessByName('headset-battery-indicator.exe')
KillProcessByName('arctis-battery-indicator.exe')
Result := ''; // Empty string means continue installation
end;