-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
SickChill.iss
608 lines (517 loc) · 21.4 KB
/
SickChill.iss
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#include <.\idp\idp.iss>
#define SickChillInstallerVersion "v0.6.2"
#define AppId "{{B0D7EA3E-CC34-4BE6-95D5-3C3D31E9E1B2}"
#define AppName "SickChill"
#define AppVersion "master"
#define AppPublisher "SickChill"
#define AppURL "http://sickchill.github.io/"
#define AppServiceName AppName
#define AppServiceDescription "Automatic Video Library Manager for TV Shows"
#define ServiceStartIcon "{group}\Start " + AppName + " Service"
#define ServiceStopIcon "{group}\Stop " + AppName + " Service"
#define DefaultPort 8081
#define InstallerVersion 10011
#define InstallerSeedUrl "https://raw.githubusercontent.com/SickChill/windows-sickchill/master/seed.ini"
#define AppRepoUrl "https://github.com/SickChill/SickChill.git"
[Setup]
AppId={#AppId}
AppName={#AppName}
AppCopyright=Copyright (C) 2016 SickChill
AppVersion={#AppVersion}
AppVerName={#AppName} ({#AppVersion})
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}
AppUpdatesURL={#AppURL}
DefaultDirName={sd}\{#AppName}
DefaultGroupName={#AppName}
AllowNoIcons=yes
DisableWelcomePage=no
DisableDirPage=no
DisableProgramGroupPage=no
ArchitecturesInstallIn64BitMode=x64
OutputBaseFilename={#AppName}Installer
SolidCompression=yes
UninstallDisplayIcon={app}\Installer\sickchill.ico
UninstallFilesDir={app}\Installer
ExtraDiskSpaceRequired=524288000
SetupIconFile=assets\sickchill.ico
WizardImageFile=assets\Wizard.bmp
WizardSmallImageFile=assets\WizardSmall.bmp
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "assets\sickchill.ico"; DestDir: "{app}\Installer"
Source: "assets\github.ico"; DestDir: "{app}\Installer"
Source: "utils\nssm32.exe"; DestDir: "{app}\Installer"; DestName: "nssm.exe"; Check: not Is64BitInstallMode
Source: "utils\nssm64.exe"; DestDir: "{app}\Installer"; DestName: "nssm.exe"; Check: Is64BitInstallMode
[Dirs]
Name: "{app}\Data"
[Icons]
Name: "{group}\{#AppName}"; Filename: "http://localhost:{code:GetWebPort}/"; IconFilename: "{app}\Installer\sickchill.ico"
Name: "{commondesktop}\{#AppName}"; Filename: "http://localhost:{code:GetWebPort}/"; IconFilename: "{app}\Installer\sickchill.ico"; Tasks: desktopicon
Name: "{group}\{cm:ProgramOnTheWeb,{#AppName}}"; Filename: "{#AppURL}"; IconFilename: "{app}\Installer\sickchill.ico"; Flags: excludefromshowinnewinstall
Name: "{group}\{#AppName} on GitHub"; Filename: "{#AppRepoUrl}"; IconFilename: "{app}\Installer\github.ico"; Flags: excludefromshowinnewinstall
Name: "{#ServiceStartIcon}"; Filename: "{app}\Installer\nssm.exe"; Parameters: "start ""{#AppServiceName}"""; Flags: excludefromshowinnewinstall
Name: "{#ServiceStopIcon}"; Filename: "{app}\Installer\nssm.exe"; Parameters: "stop ""{#AppServiceName}"""; Flags: excludefromshowinnewinstall
Name: "{group}\Edit {#AppName} Service"; Filename: "{app}\Installer\nssm.exe"; Parameters: "edit ""{#AppServiceName}"""; AfterInstall: ModifyServiceLinks; Flags: excludefromshowinnewinstall
[Run]
;SickChill
Filename: "{app}\Python3\tools\python.exe"; Parameters: "-m pip install sickchill"; StatusMsg: "Installing {#AppName}..."
;Filename: "xcopy.exe"; Parameters: """C:\SRinstaller\SickChill"" ""{app}\{#AppName}"" /E /I /H /Y"; Flags: runminimized; StatusMsg: "Installing {#AppName}..."
;Service
Filename: "{app}\Installer\nssm.exe"; Parameters: "start ""{#AppServiceName}"""; Flags: runhidden; BeforeInstall: CreateService; StatusMsg: "Starting {#AppName} service..."
;Firewall
Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""{#AppServiceName} In"" program=""{app}\Python3\tools\python.exe"" dir=in action=allow enable=yes"; Flags: runhidden;
Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""{#AppServiceName} Out"" program=""{app}\Python3\tools\python.exe"" dir=out action=allow enable=yes"; Flags: runhidden;
;Open
Filename: "http://localhost:{code:GetWebPort}/"; Flags: postinstall shellexec; Description: "Open {#AppName} in browser"
[UninstallRun]
;Service
Filename: "{app}\Installer\nssm.exe"; Parameters: "remove ""{#AppServiceName}"" confirm"; Flags: runhidden
;Firewall
Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall delete rule name=""{#AppServiceName} In"""; Flags: runhidden;
Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall delete rule name=""{#AppServiceName} Out"""; Flags: runhidden;
[UninstallDelete]
Type: filesandordirs; Name: "{app}\Python3"
Type: filesandordirs; Name: "{app}\Python"
Type: filesandordirs; Name: "{app}\{#AppName}"
Type: dirifempty; Name: "{app}"
[Messages]
WelcomeLabel2=This will install [name/ver] on your computer.%n%nYou will need Internet connectivity in order to download the required packages.%n%nNOTE: This installer intentionally ignores any existing installations of Git or Python you might already have installed on your system. If you would prefer to use those versions, we recommend installing [name] manually.
AboutSetupNote=SickChillInstaller {#SickChillInstallerVersion}
BeveledLabel=SickChillInstaller {#SickChillInstallerVersion}
[Code]
type
TDependency = record
Name: String;
URL: String;
Filename: String;
Size: Integer;
SHA1: String;
end;
IShellLinkW = interface(IUnknown)
'{000214F9-0000-0000-C000-000000000046}'
procedure Dummy;
procedure Dummy2;
procedure Dummy3;
function GetDescription(pszName: String; cchMaxName: Integer): HResult;
function SetDescription(pszName: String): HResult;
function GetWorkingDirectory(pszDir: String; cchMaxPath: Integer): HResult;
function SetWorkingDirectory(pszDir: String): HResult;
function GetArguments(pszArgs: String; cchMaxPath: Integer): HResult;
function SetArguments(pszArgs: String): HResult;
function GetHotkey(var pwHotkey: Word): HResult;
function SetHotkey(wHotkey: Word): HResult;
function GetShowCmd(out piShowCmd: Integer): HResult;
function SetShowCmd(iShowCmd: Integer): HResult;
function GetIconLocation(pszIconPath: String; cchIconPath: Integer;
out piIcon: Integer): HResult;
function SetIconLocation(pszIconPath: String; iIcon: Integer): HResult;
function SetRelativePath(pszPathRel: String; dwReserved: DWORD): HResult;
function Resolve(Wnd: HWND; fFlags: DWORD): HResult;
function SetPath(pszFile: String): HResult;
end;
IPersist = interface(IUnknown)
'{0000010C-0000-0000-C000-000000000046}'
function GetClassID(var classID: TGUID): HResult;
end;
IPersistFile = interface(IPersist)
'{0000010B-0000-0000-C000-000000000046}'
function IsDirty: HResult;
function Load(pszFileName: String; dwMode: Longint): HResult;
function Save(pszFileName: String; fRemember: BOOL): HResult;
function SaveCompleted(pszFileName: String): HResult;
function GetCurFile(out pszFileName: String): HResult;
end;
IShellLinkDataList = interface(IUnknown)
'{45E2B4AE-B1C3-11D0-B92F-00A0C90312E1}'
procedure Dummy;
procedure Dummy2;
procedure Dummy3;
function GetFlags(out dwFlags: DWORD): HResult;
function SetFlags(dwFlags: DWORD): HResult;
end;
const
MinPort = 1;
MaxPort = 65535;
WM_CLOSE = $0010;
GENERIC_WRITE = $40000000;
GENERIC_READ = $80000000;
OPEN_EXISTING = 3;
INVALID_HANDLE_VALUE = $FFFFFFFF;
SLDF_RUNAS_USER = $00002000;
CLSID_ShellLink = '{00021401-0000-0000-C000-000000000046}';
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
var
// This lets AbortInstallation() terminate setup without prompting the user
CancelWithoutPrompt: Boolean;
ErrorMessage, LocalFilesDir: String;
SeedDownloadPageId, DependencyDownloadPageId: Integer;
PythonDep: TDependency;
InstallDepPage: TOutputProgressWizardPage;
OptionsPage: TInputQueryWizardPage;
// Uninstall variables
UninstallRemoveData: Boolean;
// Import some Win32 functions
function CreateFile(
lpFileName: String;
dwDesiredAccess: LongWord;
dwSharedMode: LongWord;
lpSecurityAttributes: LongWord;
dwCreationDisposition: LongWord;
dwFlagsAndAttributes: LongWord;
hTemplateFile: LongWord): LongWord;
external 'CreateFileW@kernel32.dll stdcall';
function CloseHandle(hObject: LongWord): Boolean;
external 'CloseHandle@kernel32.dll stdcall';
procedure AbortInstallation(ErrorMessage: String);
begin
MsgBox(ErrorMessage + #13#10#13#10 'Setup will now terminate.', mbError, 0)
CancelWithoutPrompt := True
PostMessage(WizardForm.Handle, WM_CLOSE, 0, 0);
end;
procedure CheckInstallerVersion(SeedFile: String);
var
InstallerVersion, CurrentVersion: Integer;
DownloadUrl: String;
begin
InstallerVersion := StrToInt(ExpandConstant('{#InstallerVersion}'))
CurrentVersion := GetIniInt('Installer', 'Version', 0, 0, MaxInt, SeedFile)
if CurrentVersion = 0 then begin
AbortInstallation('Unable to parse configuration.')
end;
if CurrentVersion > InstallerVersion then begin
DownloadUrl := GetIniString('Installer', 'DownloadUrl', ExpandConstant('{#AppURL}'), SeedFile)
AbortInstallation(ExpandConstant('This is an old version of the {#AppName} installer. Please get the latest version at:') + #13#10#13#10 + DownloadUrl)
end;
end;
procedure ParseDependency(var Dependency: TDependency; Name, SeedFile: String);
var
LocalFile: String;
begin
Dependency.Name := Name;
Dependency.URL := GetIniString(Name, 'url', '', SeedFile)
Dependency.Filename := GetIniString(Name, 'filename', Dependency.URL, SeedFile)
Dependency.Size := GetIniInt(Name, 'size', 0, 0, MaxInt, SeedFile)
Dependency.SHA1 := GetIniString(Name, 'sha1', '', SeedFile)
if (Dependency.URL = '') or (Dependency.Size = 0) or (Dependency.SHA1 = '') then begin
AbortInstallation('Error parsing dependency information for ' + Name + '.')
end;
while Pos('/', Dependency.Filename) <> 0 do begin
Delete(Dependency.Filename, 1, Pos('/', Dependency.Filename))
end;
if LocalFilesDir <> '' then begin
LocalFile := LocalFilesDir + '\' + Dependency.Filename
end;
if (LocalFile <> '') and (FileExists(LocalFile)) then begin
FileCopy(LocalFile, ExpandConstant('{tmp}\') + Dependency.Filename, True)
end else begin
idpAddFileSize(Dependency.URL, ExpandConstant('{tmp}\') + Dependency.Filename, Dependency.Size)
end
end;
procedure ParseSeedFile();
var
SeedFile: String;
Arch: String;
DownloadPage: TWizardPage;
begin
SeedFile := ExpandConstant('{tmp}\installer.ini')
// Make sure we're running the latest version of the installer
CheckInstallerVersion(SeedFile)
if Is64BitInstallMode then
Arch := 'x64'
else
Arch := 'x86';
ParseDependency(PythonDep, 'Python.' + Arch, SeedFile)
DependencyDownloadPageId := idpCreateDownloadForm(wpPreparing)
DownloadPage := PageFromID(DependencyDownloadPageId)
DownloadPage.Caption := 'Downloading Dependencies'
DownloadPage.Description := ExpandConstant('Setup is downloading {#AppName} dependencies...')
idpSetOption('DetailedMode', '1')
idpSetOption('DetailsButton', '0')
idpConnectControls()
end;
procedure InitializeSeedDownload();
var
DownloadPage: TWizardPage;
Seed: String;
IsRemote: Boolean;
begin
IsRemote := True
Seed := ExpandConstant('{param:SEED}')
if (Lowercase(Copy(Seed, 1, 7)) <> 'http://') and (Lowercase(Copy(Seed, 1, 8)) <> 'https://') then begin
if Seed = '' then begin
Seed := ExpandConstant('{#InstallerSeedUrl}')
end else begin
if FileExists(Seed) then begin
IsRemote := False
end else begin
MsgBox('Invalid SEED specified: ' + Seed, mbError, 0)
Seed := ExpandConstant('{#InstallerSeedUrl}')
end;
end;
end;
if not IsRemote then begin
FileCopy(Seed, ExpandConstant('{tmp}\installer.ini'), False)
ParseSeedFile()
end else begin
// Download the installer seed INI file
// I'm adding a dummy size here otherwise the installer crashes (divide by 0)
// when runnning in silent mode, a bug in IDP maybe?
idpAddFileSize(Seed, ExpandConstant('{tmp}\installer.ini'), 1024)
SeedDownloadPageId := idpCreateDownloadForm(wpWelcome)
DownloadPage := PageFromID(SeedDownloadPageId)
DownloadPage.Caption := 'Downloading Installer Configuration'
DownloadPage.Description := 'Setup is downloading its configuration file...'
idpConnectControls()
end;
end;
function CheckFileInUse(Filename: String): Boolean;
var
FileHandle: LongWord;
begin
if not FileExists(Filename) then begin
Result := False
exit
end;
FileHandle := CreateFile(Filename, GENERIC_READ or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
if (FileHandle <> 0) and (FileHandle <> INVALID_HANDLE_VALUE) then begin
CloseHandle(FileHandle)
Result := False
end else begin
Result := True
end;
end;
function GetWebPort(Param: String): String;
begin
Result := OptionsPage.Values[0]
end;
procedure CreateService();
var
Nssm: String;
ResultCode: Integer;
OldProgressString: String;
WindowsVersion: TWindowsVersion;
begin
Nssm := ExpandConstant('{app}\Installer\nssm.exe')
GetWindowsVersionEx(WindowsVersion);
OldProgressString := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := ExpandConstant('Installing {#AppName} service...')
Exec(Nssm, ExpandConstant('install "{#AppServiceName}" "{app}\Python3\tools\python.exe" """{app}\Python3\tools\Scripts\SickChill.exe""" --nolaunch --port='+GetWebPort('')+' --datadir="""{app}\Data"""'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppDirectory "{app}\Data"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" Description "{#AppServiceDescription}"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppStopMethodSkip 6'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppStopMethodConsole 20000'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
if WindowsVersion.NTPlatform and (WindowsVersion.Major >= 10) and (WindowsVersion.Build > 14393) then begin
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppNoConsole 1'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
end;
WizardForm.StatusLabel.Caption := OldProgressString;
end;
procedure StopService();
var
Nssm: String;
ResultCode: Integer;
Retries: Integer;
OldProgressString: String;
begin
Retries := 30
OldProgressString := UninstallProgressForm.StatusLabel.Caption;
UninstallProgressForm.StatusLabel.Caption := ExpandConstant('Stopping {#AppName} service...')
Nssm := ExpandConstant('{app}\Installer\nssm.exe')
Exec(Nssm, ExpandConstant('stop "{#AppServiceName}"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
while (Retries > 0) and (CheckFileInUse(Nssm)) do begin
UninstallProgressForm.StatusLabel.Caption := ExpandConstant('Waiting for {#AppName} service to stop (') + IntToStr(Retries) + ')...'
Sleep(1000)
Retries := Retries - 1
end;
UninstallProgressForm.StatusLabel.Caption := OldProgressString;
end;
procedure CleanPython();
var
PythonPath: String;
begin
PythonPath := ExpandConstant('{app}\Python3\tools')
DelTree(PythonPath + '\*.msi', False, True, False)
DelTree(PythonPath + '\Doc', True, True, True)
DelTree(PythonPath + '\Lib\test\*.*', False, True, True)
DelTree(PythonPath + '\Scripts', True, True, True)
DelTree(PythonPath + '\tcl', True, True, True)
DelTree(PythonPath + '\Tools', True, True, True)
end;
procedure InstallPython();
var
ResultCode: Integer;
Shell: Variant;
ZipPath: Variant;
ZipFile: Variant;
TargetPath: Variant;
TargetFolder: Variant;
PythonPTHFile: Variant;
begin
InstallDepPage.SetText('Installing Python...', '')
Shell := CreateOleObject('Shell.Application');
if VarIsClear(Shell) then
AbortInstallation('Failed to create Shell.Application');
ZipPath := ExpandConstantEx('{tmp}\{filename}', 'filename', PythonDep.Filename);
if VarIsClear(ZipPath) then
AbortInstallation('ZIP Path failed');
ZipFile := Shell.NameSpace(ZipPath);
if VarIsClear(ZipFile) then
AbortInstallation('ZIP file does not exist or cannot be opened');
TargetPath := ExpandConstant('{app}\Python3');
if ForceDirectories(TargetPath) then
begin
TargetFolder := Shell.NameSpace(TargetPath);
if VarIsClear(TargetFolder) then
AbortInstallation('Could not select target with shell');
end
else
AbortInstallation('Creation of folder failed!');
TargetFolder.CopyHere(ZipFile.Items, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
InstallDepPage.SetProgress(InstallDepPage.ProgressBar.Position+1, InstallDepPage.ProgressBar.Max)
ResultCode := 0
end;
function VerifyDependency(Dependency: TDependency): Boolean;
begin
Result := True
InstallDepPage.SetText('Verifying dependency files...', Dependency.Filename)
if GetSHA1OfFile(ExpandConstant('{tmp}\') + Dependency.Filename) <> Dependency.SHA1 then begin
MsgBox('SHA1 hash of ' + Dependency.Filename + ' does not match.', mbError, 0)
Result := False
end;
InstallDepPage.SetProgress(InstallDepPage.ProgressBar.Position+1, InstallDepPage.ProgressBar.Max)
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if ErrorMessage <> '' then begin
Result := ErrorMessage
end;
end;
procedure InstallDependencies();
begin
try
InstallDepPage.Show
InstallDepPage.SetProgress(0, 6)
if VerifyDependency(PythonDep) then begin
InstallPython()
end else begin
ErrorMessage := 'There was an error installing the required dependencies.'
end;
finally
InstallDepPage.Hide
end;
end;
procedure InitializeWizard();
begin
InitializeSeedDownload()
idpInitMessages()
InstallDepPage := CreateOutputProgressPage('Installing Dependencies', ExpandConstant('Setup is installing {#AppName} dependencies...'));
OptionsPage := CreateInputQueryPage(wpSelectProgramGroup, 'Additional Options', ExpandConstant('Additional {#AppName} configuration options'), '');
OptionsPage.Add(ExpandConstant('{#AppName} Web Server Port:'), False)
OptionsPage.Values[0] := ExpandConstant('{#DefaultPort}')
end;
function ShellLinkRunAsAdmin(LinkFilename: String): Boolean;
var
Obj: IUnknown;
SL: IShellLinkW;
PF: IPersistFile;
DL: IShellLinkDataList;
Flags: DWORD;
begin
try
Obj := CreateComObject(StringToGuid(CLSID_ShellLink));
SL := IShellLinkW(Obj);
PF := IPersistFile(Obj);
// Load the ShellLink
OleCheck(PF.Load(LinkFilename, 0));
// Set the SLDF_RUNAS_USER flag
DL := IShellLinkDataList(Obj);
OleCheck(DL.GetFlags(Flags))
OleCheck(DL.SetFlags(Flags or SLDF_RUNAS_USER))
// Save the ShellLink
OleCheck(PF.Save(LinkFilename, True));
Result := True
except
Result := False
end;
end;
procedure ModifyServiceLinks();
begin
ShellLinkRunAsAdmin(ExpandConstant('{#ServiceStartIcon}.lnk'))
ShellLinkRunAsAdmin(ExpandConstant('{#ServiceStopIcon}.lnk'))
end;
function InitializeSetup(): Boolean;
begin
CancelWithoutPrompt := False
LocalFilesDir := ExpandConstant('{param:LOCALFILES}')
if (LocalFilesDir <> '') and (not DirExists(LocalFilesDir)) then begin
MsgBox('Invalid LOCALFILES specified: ' + LocalFilesDir, mbError, 0)
LocalFilesDir := ''
end;
// Don't allow installations over top
if RegKeyExists(HKEY_LOCAL_MACHINE, ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1')) then begin
MsgBox(ExpandConstant('{#AppName} is already installed. If you''re reinstalling or upgrading, please uninstall the current version first.'), mbError, 0)
Result := False
end else begin
Result := True
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
Port: Integer;
begin
Result := True
if CurPageID = SeedDownloadPageId then begin
ParseSeedFile()
end else if CurPageId = OptionsPage.ID then begin
// Make sure valid port is specified
Port := StrToIntDef(OptionsPage.Values[0], 0)
if (Port = 0) or (Port < MinPort) or (Port > MaxPort) then begin
MsgBox(FmtMessage('Please specify a valid port between %1 and %2.', [IntToStr(MinPort), IntToStr(MaxPort)]), mbError, 0)
Result := False;
end;
end;
end;
function UninstallShouldRemoveData(): Boolean;
begin
Result := MsgBox(ExpandConstant('Do you want to remove your {#AppName} database and configuration?' #13#10#13#10 'Select No if you plan on reinstalling {#AppName}.'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm := not CancelWithoutPrompt;
end;
procedure InitializeUninstallProgressForm();
begin
UninstallRemoveData := UninstallShouldRemoveData()
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then begin
// Stop service
StopService()
// Remove data if requested
if UninstallRemoveData then begin
DelTree(ExpandConstant('{app}\Data'), True, True, True)
end;
end;
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo,
MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
begin
Result := MemoDirInfo + NewLine + NewLine + \
MemoGroupInfo + NewLine + NewLine + \
'Download and install dependencies:' + NewLine + \
Space + 'Python' + NewLine + NewLine + \
'Web server port:' + NewLine + Space + GetWebPort('')
if MemoTasksInfo <> '' then begin
Result := Result + NewLine + NewLine + MemoTasksInfo
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then begin
InstallDependencies()
end;
end;