Dominic Cabral
Dominic Cabral

Reputation: 962

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

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

Upvotes: 3

Views: 273

Answers (1)

Dominic Cabral
Dominic Cabral

Reputation: 962

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;

Upvotes: 1

Related Questions