From ac85a8ca3a19d65ff150c38ebe0e14e3376a51c0 Mon Sep 17 00:00:00 2001 From: James Fantin-Hardesty <24646452+jfantinhardesty@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:28:19 -0600 Subject: [PATCH] Fix inno setup paths cloudfuse (#294) * Only change system path to add cloudfuse * Fix issue --- build/windows_installer_build.iss | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/build/windows_installer_build.iss b/build/windows_installer_build.iss index c71eb884b..8e19feb3a 100644 --- a/build/windows_installer_build.iss +++ b/build/windows_installer_build.iss @@ -34,6 +34,8 @@ ArchitecturesInstallIn64BitMode=x64 SignTool=signtool /d $q{#MyAppName} v{#MyAppVersion}$q $f SignedUninstaller=yes VersionInfoVersion={#MyAppVersion} +; Tell Windows Explorer to reload the environment +ChangesEnvironment=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -69,10 +71,31 @@ Source: "..\winfsp-2.0.23075.msi"; DestDir: "{app}"; Flags: ignoreversion Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon +[Registry] +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \ + ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \ + Check: NeedsAddPath('{app}') + [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [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; + var ResultCode: Integer; @@ -92,12 +115,6 @@ begin end; end; - // Add cloudfuse to the path - if not Exec('cmd.exe', '/C SETX PATH "%PATH%;' + ExpandConstant('{app}') +'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then - begin - MsgBox('Failed to update PATH. You may need to add the path manually to use Cloudfuse on the command line.', mbError, MB_OK); - end; - // Install the Cloudfuse Startup Tool if not Exec(ExpandConstant('{app}\{#MyAppExeCLIName}'), 'service install', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin