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