-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.iss
74 lines (65 loc) · 1.82 KB
/
setup.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
[Setup]
AppName=RstEyeApp
AppVersion=1.0
DefaultDirName={pf}\RstEyeApp
DefaultGroupName=RstEyeApp
OutputDir=dist
OutputBaseFilename=RstEyeAppInstaller
Compression=lzma
SolidCompression=yes
[Files]
Source: "dist\RstEyeApp.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "med.gif"; DestDir: "{app}"; Flags: ignoreversion
[Icons]
Name: "{group}\RstEyeApp"; Filename: "{app}\RstEyeApp.exe"
[Run]
Filename: "{app}\RstEyeApp.exe"; Description: "{cm:LaunchProgram,RstEyeApp}"; Flags: nowait postinstall skipifsilent
[Code]
const
ServiceName = 'RstEyeAppService';
function IsServiceInstalled: Boolean;
var
ResultCode: Integer;
begin
Result := Exec('sc', 'query ' + ServiceName, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0);
end;
function InstallService: Boolean;
var
ResultCode: Integer;
begin
Result := Exec('sc', 'create ' + ServiceName + ' binPath= "' + ExpandConstant('{app}\RstEyeApp.exe') + '" start= auto', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0);
end;
function StartService: Boolean;
var
ResultCode: Integer;
begin
Result := Exec('sc', 'start ' + ServiceName, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
if not IsServiceInstalled then
begin
if InstallService then
begin
MsgBox('Service installed successfully.', mbInformation, MB_OK);
end
else
begin
MsgBox('Failed to install service.', mbError, MB_OK);
end;
end;
if IsServiceInstalled then
begin
if StartService then
begin
MsgBox('Service started successfully.', mbInformation, MB_OK);
end
else
begin
MsgBox('Failed to start service.', mbError, MB_OK);
end;
end;
end;
end;