Is it possible to disable silent and verysilent uninstall in Inno Setup?
2 Answers
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.

- 23,876
- 7
- 71
- 156
-
You are missing the `Exit;` after when you set the `Result` to False to interrupt the installer. But wouldn't be better to execute the setup executable from `ExpandConstant('{srcexe}')` without `/SILENT` parameter (don't know if it's possible) ? +1 in the meantime.. – TLama May 30 '12 at 15:54
-
@TLama: Oopos, I've adjusted to have a better default, this may be easier depending on what else needs to go into that function. As for re running `{srcexe}`, `[Code]` runs in the elevated part of the setup so the new non silent one will also be elevated, breaking the `...asoriginaluser` functionality. – Deanna May 31 '12 at 09:03
-
1@TLama: I'm talking rubbish, it can just use the `ExecAsOriginalUser()` function :o) – Deanna May 31 '12 at 09:06
-
I want to disable silent uninstall, not install. I tried to call `WizardSilent()` in `InitializeUninstall()` function but I got the following message: `Cannot call WIZARDSILENT function during Uninstall` – Piotr Surma Jun 18 '12 at 14:16
-
@Deanna: the code: `function InitializeUninstall(): Boolean; begin if WizardSilent() then begin MsgBox('...', mbError, MB_OK); result := false; end; end;` – Piotr Surma Jun 18 '12 at 14:27
-
Then use `UninstallSilent()`. – Deanna Jun 18 '12 at 14:45
Can use parameter like "/SP-, /SILENT, /VERYSILENT", So that every wizard page will disable or hidden. In innosetup click "Tool"-->"Parameter" and save the above parameters and build the application and run your test. Mostly this will help you for upload in microsoft app store. You can use the parameter in microsoft app store silent install parameters.

- 1
- 1