mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-14 22:55:40 +00:00
71 lines
2.2 KiB
Plaintext
71 lines
2.2 KiB
Plaintext
|
[Setup]
|
||
|
AppName=Wasmer
|
||
|
AppVersion=1.5
|
||
|
DefaultDirName={pf}\Wasmer
|
||
|
DefaultGroupName=Wasmer
|
||
|
Compression=lzma2
|
||
|
SolidCompression=yes
|
||
|
OutputDir=.\
|
||
|
DisableProgramGroupPage=yes
|
||
|
ChangesEnvironment=yes
|
||
|
OutputBaseFilename=WasmerInstaller
|
||
|
|
||
|
[Files]
|
||
|
Source: "..\target\release\wasmer.exe"; DestDir: "{app}\bin"
|
||
|
|
||
|
[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;
|
||
|
|
||
|
{ App string to the end of the path variable }
|
||
|
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;
|
||
|
|
||
|
{ Skip if string not found in path }
|
||
|
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
|
||
|
if P = 0 then exit;
|
||
|
|
||
|
{ Update path variable }
|
||
|
Delete(Paths, P - 1, Length(Path) + 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
|
||
|
then EnvAddPath(ExpandConstant('{app}') +'\bin');
|
||
|
end;
|
||
|
|
||
|
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
|
||
|
begin
|
||
|
if CurUninstallStep = usPostUninstall
|
||
|
then EnvRemovePath(ExpandConstant('{app}') +'\bin');
|
||
|
end;
|