Search code examples
windowsinstallationinno-setuppascalscript

Inno Setup, install only on a non existent directory


I would like to not permit the installation on an existent directory or at least a non-empty one.

Right now I am using this workaround just to check if the program was installed in the directory chosen by the user but this doesn't work if it is a directory where the program was not installed or a non empty one.

function NextButtonClick(PageId: Integer): Boolean;
begin
    Result := True;
    if (PageId = wpSelectDir) and  FileExists(ExpandConstant('{app}\some_app_file')) then
    begin
        MsgBox('Warning message, cannot continue.', mbError, MB_OK);
        Result := False;
        exit;
    end;
end;

I have the DirExistsWarning=yes directive but it's not enough.

Thanks for the help.


Solution

  • Use DirExists(ExpandConstant('{app}')) to check for an existence of the selected directory.