-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogUploaderService_Setup_script.iss
More file actions
114 lines (98 loc) · 3.9 KB
/
Copy pathLogUploaderService_Setup_script.iss
File metadata and controls
114 lines (98 loc) · 3.9 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
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Luminosa Log Uploader"
#include "version.iss"
#define MyAppPublisher "PicoQuant Support"
#define MyAppURL "https://support.picoquant.com"
#define MyAppExeName "loguploaderservice.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{EC5738FF-E229-4BB2-9438-ACD2BD11AAC8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
PrivilegesRequired=admin
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=Luminosa Log Uploader Setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "VERSION"; DestDir: "{app}"; Flags: ignoreversion
Source: "updater\update.ps1"; DestDir: "{app}\updater"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
[Run]
Filename: "{app}\{#MyAppExeName}"; Parameters: "--startup delayed install"; Flags: skipifsilent runascurrentuser runhidden
Filename: "{app}\{#MyAppExeName}"; Parameters: "start"; Flags: skipifsilent runascurrentuser runhidden
[UninstallRun]
Filename: "{app}\{#MyAppExeName}"; Parameters: "stop"; Flags: runhidden; RunOnceId: "StopService"
Filename: "{app}\{#MyAppExeName}"; Parameters: "remove"; Flags: runhidden; RunOnceId: "RemoveService"
[Code]
function EnsureDir(const Dir: string): Boolean;
begin
if DirExists(Dir) then
Result := True
else
Result := ForceDirectories(Dir);
end;
procedure WriteTaskLog(const S: string);
var
LogDir: string;
LogPath: string;
begin
LogDir := ExpandConstant('{commonappdata}\\PicoQuant\\LuminosaLogUploader\\update');
EnsureDir(LogDir);
LogPath := LogDir + '\\installer_task.log';
SaveStringToFile(LogPath, S + #13#10, True);
end;
function CreateAutoUpdateTask(): Boolean;
var
ResultCode: Integer;
TaskName: string;
Tr: string;
Params: string;
Started: Boolean;
begin
TaskName := '\PicoQuant\LuminosaLogUploader\AutoUpdate';
Tr := '\"powershell.exe\" -NoProfile -ExecutionPolicy Bypass -File \"' + ExpandConstant('{app}\updater\update.ps1') + '\"';
Params := '/Create /F /RL HIGHEST /RU SYSTEM /SC ONSTART /DELAY 0000:30 /TN "' + TaskName + '" /TR "' + Tr + '"';
WriteTaskLog('Creating task: ' + Params);
Started := Exec(ExpandConstant('{sys}\\schtasks.exe'), Params, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
WriteTaskLog('schtasks started=' + IntToStr(Ord(Started)) + ' exit=' + IntToStr(ResultCode));
Result := Started and (ResultCode = 0);
end;
function DeleteAutoUpdateTask(): Boolean;
var
ResultCode: Integer;
TaskName: string;
Params: string;
begin
TaskName := '\PicoQuant\LuminosaLogUploader\AutoUpdate';
Params := '/Delete /F /TN "' + TaskName + '"';
Result := Exec(ExpandConstant('{sys}\\schtasks.exe'), Params, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Result := Result and (ResultCode = 0);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
CreateAutoUpdateTask();
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
DeleteAutoUpdateTask();
end;