-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathMouseTracks.iss
More file actions
152 lines (120 loc) · 5.16 KB
/
MouseTracks.iss
File metadata and controls
152 lines (120 loc) · 5.16 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; Command: ISCC.exe /DMyAppVersion="2.0.0" /DMySourceBaseName="dist\MouseTracks-2.0.0-windows-x64" /DMyDestinationBaseName="dist\MouseTracks-2.0.0-windows-x64-setup" MouseTracks.iss
#define MyAppName "MouseTracks"
; You can either hardcode the version here or pass it in via command line
; using /DMyAppVersion="2.0.0" when compiling.
#ifndef MyAppVersion
#define MyAppVersion "2.0.0"
#endif
; Define the path to the source executable
; Example: MouseTracks-2.0.0-windows-x64
#ifndef MySourceBaseName
#define MySourceBaseName "dist\MouseTracks"
#endif
; Define the full path to the output installer
#ifndef MyDestinationBaseName
#define MyDestinationBaseName "dist\MouseTracksSetup"
#endif
#define MyAppPublisher "Peter Hunt"
#define MyAppURL "https://github.com/huntfx/MouseTracks"
[Setup]
AppId={{4FABD8FD-8B74-42D0-A4B6-A8F96BDCBBAD}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}/issues
AppUpdatesURL={#MyAppURL}/releases
UninstallDisplayName={#MyAppName}
UninstallDisplayIcon={app}\icon.ico
VersionInfoVersion={#MyAppVersion}
VersionInfoProductVersion={#MyAppVersion}
VersionInfoDescription={#MyAppName} {#MyAppVersion} Setup
VersionInfoProductName={#MyAppName}
VersionInfoCopyright=Peter Hunt
DefaultDirName={localappdata}\{#MyAppName}
; Support appdata installs only
PrivilegesRequired=lowest
; Create a "MouseTracks" folder in the Start Menu
DefaultGroupName={#MyAppName}
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableWelcomePage=no
Compression=lzma2
SolidCompression=yes
; Extract the directory and filename from MyDestinationBaseName
OutputDir={#ExtractFilePath(MyDestinationBaseName)}
OutputBaseFilename={#ExtractFileName(MyDestinationBaseName)}
SetupIconFile=resources\images\icon.ico
LicenseFile=LICENSE.md
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
; Tells the installer to check if the app is running
CloseApplications=yes
RestartApplications=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "autostart"; Description: "Launch {#MyAppName} automatically when Windows starts"; GroupDescription: "Startup options:"
Name: "startminimised"; Description: "Minimise to the system tray on startup"; GroupDescription: "Startup options:"
[Registry]
; Write to the standard Windows "Run" key for the current user
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: """{app}\{#MyAppName}.exe"" --installed --autostart{code:GetStartupArgs}"; Flags: uninsdeletevalue; Tasks: autostart
[Files]
Source: "dist\{#MyAppName}.exe"; DestDir: "{app}"; DestName: "{#MyAppName}.exe"; Flags: ignoreversion
Source: "{#MySourceBaseName}.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "README.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "LICENSE.md"; DestDir: "{app}"; Flags: ignoreversion
; Source: "config\*"; DestDir: "{app}\config"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "resources\images\icon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion
[Icons]
; Start Menu shortcut
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppName}.exe"
; Desktop shortcut
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppName}.exe"; Tasks: desktopicon
[Run]
; Launch the app after installation is complete
Filename: "{app}\{#MyAppName}.exe"; Parameters: "--post-install{code:GetStartupArgs}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
// Function to dynamically determine startup arguments based on selected tasks
function GetStartupArgs(Param: String): String;
begin
// Check if the "Start minimised" task is checked
if WizardIsTaskSelected('startminimised') then
begin
Result := ' --start-hidden';
end
else
begin
Result := ' --start-visible';
end;
end;
// Function to check if the application is currently running
function InitializeSetup(): Boolean;
var
WbemLocator, WbemServices, WbemObjectSet: Variant;
TargetFile: String;
begin
Result := True;
TargetFile := ExpandConstant('{localappdata}\{#MyAppName}\{#MyAppName}.exe');
StringChange(TargetFile, '\', '\\');
try
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('.', 'root\CIMV2');
WbemObjectSet := WbemServices.ExecQuery('SELECT Name FROM Win32_Process WHERE ExecutablePath = ''' + TargetFile + '''');
if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
begin
MsgBox('MouseTracks is currently running. Please close it before installing.', mbError, MB_OK);
Result := False;
end;
except
// If WMI fails, proceed anyway
end;
end;
[UninstallDelete]
; Delete all versioned executable and temp files on uninstall
Type: files; Name: "{app}\MouseTracks-*.exe"
Type: files; Name: "{app}\*.tmp"