问题
I am trying to create an installer that is a Demo installer that if it detects the file close.txt
in the programs folder then it closes the wizard or aborts install.
I am running a scheduled task that automatically uninstalls the app after two days. On initial install the close.txt
file gets installed in the programs folder then after auto uninstall the close.txt
file is left in the programs folder. I would like for when you re run the installer it checks for this file and if it is found to close the wizard or abort install. I am a newbie at this I think it can be accomplished in the code section but I am not sure.
Any help or code snippets would be appreciated thank you!
回答1:
Test for the file existence in InitializeSetup event function and return False
, if it exists.
[Setup]
DefaultDirName={autopf}\My Program
[Code]
function WasMyProgramEverInstalled: Boolean;
begin
Result := FileExists('{#SetupSetting("DefaultDirName")}\close.txt');
end;
function InitializeSetup: Boolean;
begin
Result := True;
if WasMyProgramEverInstalled then
begin
MsgBox('Some message', mbError, MB_OK); { Optionally }
Result := False;
end;
end;
Note that if the installer allow customizing an installation path, you won't know it, when re-running the installation after uninstallation. So this won't work.
来源:https://stackoverflow.com/questions/60460128/inno-setup-close-installer-wizard-if-file-exists-in-the-programs-folder