This repository has been archived by the owner on Apr 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathintiface-cli-installer.iss
117 lines (100 loc) · 3.36 KB
/
intiface-cli-installer.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
#define Configuration GetEnv('CONFIGURATION')
#if Configuration == ""
#define Configuration "Release"
#endif
#define Version GetEnv('BUILD_VERSION')
#if Version == ""
#define Version "x.x.x.x"
#endif
[Setup]
AppName=Intiface CLI
AppVersion={#Version}
AppPublisher=Nonpolynomial Labs, LLC
AppPublisherURL=www.buttplug.io
AppId={{0a5b92f6-51e8-11e9-aa5c-0bbc873d2d19}
SetupIconFile=icons\intiface-logo-1.ico
WizardImageFile=icons\intiface-logo-1.bmp
WizardSmallImageFile=icons\intiface-logo-1.bmp
UsePreviousAppDir=yes
DefaultDirName={pf}\IntifaceCLI
Uninstallable=yes
UninstallDisplayIcon=icons\intiface-logo-1.ico
Compression=lzma2
SolidCompression=yes
OutputBaseFilename=intiface-cli-installer
OutputDir=.\installer
LicenseFile=LICENSE
[Dirs]
Name: "{localappdata}\Intiface"
[UninstallDelete]
Type: filesandordirs; Name: "{app}"
[Files]
Source: "IntifaceCLI\bin\{#Configuration}\net47\*.exe"; DestDir: "{app}"
Source: "IntifaceCLI\bin\{#Configuration}\net47\*.dll"; DestDir: "{app}"
Source: "IntifaceCLI\bin\{#Configuration}\net47\*.config"; DestDir: "{app}"
Source: "Readme.md"; DestDir: "{app}"; DestName: "Readme.txt"
Source: "LICENSE"; DestDir: "{app}"; DestName: "License.txt"
// [Run]
// Filename: "{app}\Readme.txt"; Description: "View the README file"; Flags: postinstall shellexec unchecked
[Code]
function WriteEnginePath(): Boolean;
begin
SaveStringToFile(ExpandConstant('{localappdata}\Intiface\enginepath.txt'), ExpandConstant('{app}'), False);
Result := true;
end;
// Uninstall on install code taken from https://stackoverflow.com/a/2099805/4040754
////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;
/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString
// default return value
Result := 0;
// get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;
/////////////////////////////////////////////////////////////////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then
begin
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end;
if (CurStep=ssPostInstall) then
begin
WriteEnginePath();
end;
end;