Adds /FORCEUPGRADE command line parameter

Allows skipping the upgrade confirmation prompt by providing the `/FORCEUPGRADE` command line parameter.
This enables unattended upgrades for automation scenarios.
This commit is contained in:
Flavio Fois
2026-02-11 16:54:52 +01:00
parent 547018a39f
commit 549eed065a

View File

@@ -80,6 +80,20 @@ var
PreviousVersion: String; PreviousVersion: String;
IsUpgrade: Boolean; IsUpgrade: Boolean;
// Check if a command line parameter exists
function CmdLineParamExists(const Param: string): Boolean;
var
I: Integer;
begin
Result := False;
for I := 1 to ParamCount do
if CompareText(ParamStr(I), Param) = 0 then
begin
Result := True;
Exit;
end;
end;
// Check if a previous version is installed // Check if a previous version is installed
function GetPreviousVersion(): String; function GetPreviousVersion(): String;
var var
@@ -115,13 +129,17 @@ begin
if IsUpgrade then if IsUpgrade then
begin begin
// Show upgrade message // Check for /FORCEUPGRADE parameter to skip confirmation
Message := FmtMessage(CustomMessage('UpgradeDetected'), [PreviousVersion]) + #13#10#13#10 + if not CmdLineParamExists('/FORCEUPGRADE') then
CustomMessage('UpgradeMessage');
if MsgBox(Message, mbInformation, MB_YESNO) = IDNO then
begin begin
Result := False; // Show upgrade message
Message := FmtMessage(CustomMessage('UpgradeDetected'), [PreviousVersion]) + #13#10#13#10 +
CustomMessage('UpgradeMessage');
if MsgBox(Message, mbInformation, MB_YESNO) = IDNO then
begin
Result := False;
end;
end; end;
end; end;
end; end;