Inno Setup - Check if file exist in destination or else if doesn't abort the installation
Just don't let the user proceed until they pick the correct folder.
function NextButtonClick(PageId: Integer): Boolean;begin Result := True; if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\yourapp.exe')) then begin MsgBox('YourApp does not seem to be installed in that folder. Please select the correct folder.', mbError, MB_OK); Result := False; exit; end;end;
Of course, it's also a good idea to try to automatically pick the correct folder for them, eg. by retrieving the correct location out of the registry.
Another solution would be the InitializeSetup()
:
Credit: Manfred
[code] function InitializeSetup(): Boolean; begin if (FileExists(ExpandConstant('{pf}\{#MyAppName}\somefile.exe'))) then begin MsgBox('Installation validated', mbInformation, MB_OK); Result := True; end else begin MsgBox('Abort installation', mbCriticalError, MB_OK); Result := False; end; end;