Disable silent and verysilent uninstall in Inno Se

2019-07-15 06:18发布

问题:

Is it possible to disable silent and verysilent uninstall in Inno Setup?

回答1:

You can't disable it directly, but you can check if it's running in silent mode and display a message/exit during the InitializeSetup()/InitialiseUninstall() event functions.

function InitializeSetup(): Boolean;
begin
  // Default to OK
  result := true;

  // If it's in silent mode, exit
  if WizardSilent() then
  begin
    MsgBox('This setup doesn''t support silent installations.', mbInformation, MB_OK);
    result := false;
  end;
end;

Or for uninstall:

function InitializeUninstall(): Boolean;
begin
  // Default to OK
  result := true;

  // If it's in silent mode, exit
  if UninstallSilent() then
  begin
    MsgBox('This setup doesn''t support silent uninstallation.', mbInformation, MB_OK);
    result := false;
  end;
end;

(Untested air code)

If you want to silently (??? :o) rerun the setup again in non silent mode, you can use this inside the InitializeSetup if block:

ShellExecAsOriginalUser('', ExpandConstant('{srcexe}'), '', '',  SW_SHOWNORMAL, ewNoWait, 0);

Note that this will also drop any other parameters passed and prompt for elevation again.



标签: inno-setup