Inno Setup: Close installer wizard if file exists in the program's folder

后端 未结 1 1792
广开言路
广开言路 2021-01-16 14:07

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 ins

相关标签:
1条回答
  • 2021-01-16 14:43

    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.

    0 讨论(0)
提交回复
热议问题