We've recently had an application which installs using an INNO script undergo a significant restructuring.
Unfortunately the application requires certain files to persist from version to version.
Even more unfortunately, the location of these files has changed during this restructuring.
Most unfortunately, it now falls to me to craft an INNO script fragment which will look to see if those files exist, and to move them from their former location to their new location.
Is it possible to have an INNO script check to see if files (which have nothing to do with the INNO script itself in any capacity) exist, and if they do, to move them to a new location before/after the install is completed?
I say that these files have nothing to do with the INNO script because they are user-generated content.
Yes, it is possible. The code below is a copy and delete (instead of a raw move or rename).
Use the [Code]
section to implement this logic.
The documentation about supported functions and the events you can handle is pretty good.
How to react on a beginning installation:
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssInstall:
begin
{ will be executed just before the actual installation starts }
end;
ssPostInstall:
begin
{ will be executed just after the actual installation finishes }
end;
end;
end;
How to know whether a file exists or not
if FileExists(FileName) then
begin
{ do something when the file exists }
end;
Copy a file (overwrite exisiting file)
if not FileCopy(ExistingFileName, NewFileName: String, false) then
begin
{ handle copy error }
end;
Delete a file
if not DeleteFile(FileName) then
begin
{ handle delete error }
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With