InnoSetup - copy files before installation

How can we copy, move, rename user files before installation?

We can easily delete files using the [InstallDelete] section:

[InstallDelete] Type: files; Name: "{app}\SomeFile.exe"; 

Can I copy, rename in the same way?

EDIT:

I tried to do this in the [Files] section, but at compile time I get an error because the source file does not exist:

 [Files] Source: "{app}\SomeFile.exe"; DestDir: "{app}\SomeDir\SomeFile.exe"; 
+6
source share
1 answer

You can use the [Files] section to copy files, but I don’t think there is a way to move or rename operations in a separate section, so I suggest you use the [Code] section for this.

Here is sample code for move and rename operations. They both use the RenameFile function, since it is an internal operation:

 [Code] procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep = ssInstall then begin // move file if not RenameFile(ExpandConstant('{app}\SomeDir\SomeFile.exe'), ExpandConstant('{app}\SomeFile.exe')) then MsgBox('File moving failed!', mbError, MB_OK); // rename file if not RenameFile(ExpandConstant('{app}\SomeFile.exe'), ExpandConstant('{app}\RenamedSomeFile.exe')) then MsgBox('File moving failed!', mbError, MB_OK); end; end; 
+8
source

Source: https://habr.com/ru/post/945153/