-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathInstaller.iss.in
107 lines (96 loc) · 3.12 KB
/
Installer.iss.in
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
[Setup]
AppName=ArkScript
AppVersion=@ARK_VERSION_MAJOR@.@ARK_VERSION_MINOR@.@ARK_VERSION_PATCH@
AppPublisher=Alexandre Plateau
AppPublisherURL=https://arkscript-lang.dev
DefaultDirName={autopf}\ArkScript
DefaultGroupName=ArkScript
UninstallDisplayIcon={app}\MyProg.exe
; Show installation directory page
DisableDirPage=no
Compression=lzma2
SolidCompression=yes
LicenseFile=LICENCE
ChangesEnvironment=yes
; "ArchitecturesAllowed=x64" specifies that Setup cannot run on
; anything but x64.
ArchitecturesAllowed=x64
; "ArchitecturesInstallIn64BitMode=x64" requests that the install be
; done in "64-bit mode" on x64, meaning it should use the native
; 64-bit Program Files directory and the 64-bit view of the registry.
ArchitecturesInstallIn64BitMode=x64
[Dirs]
Name: "{app}\bin"
Name: "{app}\lib"
Name: "{app}\modules"
[Files]
Source: "build/Release/arkscript.exe"; DestDir: "{app}\bin"
Source: "build/Release/ArkReactor.dll"; DestDir: "{app}\bin"
Source: "lib/std/*.ark"; DestDir: "{app}\lib"
Source: "lib/std/LICENSE"; DestDir: "{app}\lib"
Source: "lib/*.arkm"; DestDir: "{app}\modules"
Source: "LICENCE"; DestDir: "{app}"
Source: "README.md"; DestDir: "{app}"; Flags: isreadme
[Icons]
Name: "{group}\ArkScript"; Filename: "{app}\bin\arkscript.exe"
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "PATH"; ValueData: "{olddata};{app}\bin"; Check: NeedsAddPath('{app}\bin')
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "ARKSCRIPT_PATH"; ValueData: "{app};{app}/lib;{app}/modules"; Flags: preservestringtype
[Code]
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OrigPath)
then begin
Result := True;
exit;
end;
{ look for the path with leading and trailing semicolon }
{ Pos() returns 0 if not found }
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
end;
const
EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
procedure RemovePath(Path: string);
var
Paths: string;
P: Integer;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
begin
Log('PATH not found');
end
else
begin
Log(Format('PATH is [%s]', [Paths]));
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
if P = 0 then
begin
Log(Format('Path [%s] not found in PATH', [Path]));
end
else
begin
if P > 1 then P := P - 1;
Delete(Paths, P, Length(Path) + 1);
Log(Format('Path [%s] removed from PATH => [%s]', [Path, Paths]));
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
begin
Log('PATH written');
end
else
begin
Log('Error writing PATH');
end;
end;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
RemovePath(ExpandConstant('{app}\bin'));
end;
end;