How can I prompt restart in Inno Setup based off command line argument?

Viewed 62

There are certain cases with my application installer where I'd want to the user to restart their device. Ideally, I'd pass an arg i.e.

Setup.exe /RESTART=yes

And withing the setup script evaluate:

AlwaysRestart={param:RESTART|no}

Unfortunatley, that is not valid:

Error on ... Setup.iss: Value of [Setup] section directive "AlwaysRestart" is invalid.
Compile aborted.

Running InnoSetup 5.6.1

1 Answers

I figured out that I am able to pass an argument and use it in the NeedsRestart event function. This will prompt the user to restart the system at the end of a successful installation if I pass /restart=1 as an argument.

[Code]
function NeedRestart(): Boolean;
begin
  Result := ExpandConstant('{param:restart|0}') = '1';
end;
Related