-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathOctosSetup.iss
More file actions
108 lines (91 loc) · 3.97 KB
/
OctosSetup.iss
File metadata and controls
108 lines (91 loc) · 3.97 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
[Setup]
AppName=Octos
AppVersion={#AppVersion}
DefaultGroupName=Octos
OutputBaseFilename=OctosSetup
Compression=lzma
SolidCompression=yes
UninstallDisplayIcon={app}\Octos.exe
ArchitecturesAllowed=x86 x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
DefaultDirName={commonpf}\Octos
ChangesEnvironment=true
DisableWelcomePage=no
WizardImageFile=./img/wizard-screen.bmp
WizardSmallImageFile=./img/small-wizard.bmp
DisableDirPage=false
OutputDir=build
DisableProgramGroupPage=yes
; LicenseFile=LICENSE
[Files]
; Source: "build\Release\Octos.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\build\x64\Release\*"; DestDir: "{app}"; Excludes: ".\build\x64\Release\img\*.png"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: Is64BitInstallMode
Source: ".\build\Win32\Release\*"; DestDir: "{app}"; Excludes: ".\build\Win32\Release\img\*.png"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: not Is64BitInstallMode
; Source: ".\vcpkg_installed\x64-windows\bin\*.dll"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\Octos"; Filename: "{app}\Octos.exe"; Tasks: startmenuicon
Name: "{group}\Uninstall Octos"; Filename: "{uninstallexe}"; Tasks: startmenuicon
Name: "{commondesktop}\Octos"; Filename: "{app}\Octos.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\Octos.exe"; Description: "Launch Octos"; Flags: nowait postinstall skipifsilent
[Tasks]
Name: desktopicon; Description: "Create a Desktop shortcut"; GroupDescription: "Additional shortcuts:"
Name: startmenuicon; Description: "Create a Start Menu shortcut"; GroupDescription: "Additional shortcuts:"
Name: envPath; Description: "Add Octos to PATH"; GroupDescription: "Add the 'octos' toolset to PATH?"
[UninstallDelete]
Type: filesandordirs; Name: "{localappdata}\Octos"
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "Octos"; ValueData: """{app}\Octos.exe"""; Flags: uninsdeletevalue
[Code]
const EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
procedure EnvAddPath(Path: string);
var
Paths: string;
begin
{ Retrieve current path (use empty string if entry not exists) }
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
Paths := '';
{ Skip if string already found in path }
if Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';') > 0 then
exit;
{ Append properly with semicolon }
if Paths <> '' then
Paths := Paths + ';';
Paths := Paths + Path;
{ Overwrite (or create if missing) path environment variable }
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
Log(Format('The [%s] added to PATH: [%s]', [Path, Paths]))
else
Log(Format('Error while adding the [%s] to PATH: [%s]', [Path, Paths]));
end;
procedure EnvRemovePath(Path: string);
var
Paths: string;
P: Integer;
begin
{ Skip if registry entry not exists }
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
exit;
{ Find string in path }
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
if P = 0 then exit;
{ Remove it safely }
Delete(Paths, P, Length(Path) + 1);
if (P <= Length(Paths)) and (Copy(Paths, P, 1) = ';') then
Delete(Paths, P, 1);
{ Overwrite path environment variable }
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
Log(Format('The [%s] removed from PATH: [%s]', [Path, Paths]))
else
Log(Format('Error while removing the [%s] from PATH: [%s]', [Path, Paths]));
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep = ssPostInstall) and WizardIsTaskSelected('envPath') then
EnvAddPath(ExpandConstant('{app}'));
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
EnvRemovePath(ExpandConstant('{app}'));
end;