From fbc95fb5ee9855122d3322a82581e56179aa6b69 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Mon, 19 Sep 2022 23:40:50 +0200 Subject: [PATCH] templates/windows/installer: Add command line flag for portable installation Users of the Installer can now specify the `/Portable` flag in addition to other flags to install as Portable. --- templates/windows/installer.iss.in | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/templates/windows/installer.iss.in b/templates/windows/installer.iss.in index 5663704e13..2a3819222f 100644 --- a/templates/windows/installer.iss.in +++ b/templates/windows/installer.iss.in @@ -154,6 +154,24 @@ begin PAnsiChar(S), SMTO_ABORTIFHUNG, 5000, MsgResult); end; +// ------------------------------------------------------------------------------------------------------------------ // +function ParamExists(Name: String): Boolean; +var + Idx: Integer; + Limit: Integer; + Param: String; +begin + Limit := ParamCount() + for Idx := 1 to Limit do begin + Param := ParamStr(Idx); + if SameText(Param, '/' + Name) then begin + Result := True; + exit; + end; + end; + Result := False; +end; + // ------------------------------------------------------------------------------------------------------------------ // var oModePageSystemChoice: TNewRadioButton; @@ -196,9 +214,15 @@ procedure OnModePageSystemChoiceClick(Sender: TObject); forward; // ------------------------------------------------------------------------------------------------------------------ // function InitializeSetup(): Boolean; begin - bIsSystemMode := IsAdmin(); - bIsUsermode := not IsAdmin(); - bIsPortableMode := False; + if ParamExists('Portable') then begin + bIsSystemMode := False; + bIsUserMode := False; + bIsPortableMode := True; + end else begin + bIsSystemMode := IsAdmin(); + bIsUserMode := not IsAdmin(); + bIsPortableMode := False; + end; Result := True; end;