Search code examples
inno-setupfile-attributes

Remove read-only attribute from existing files in Inno Setup


I'm creating a setup with Inno Setup. This setup adds files to a "main program" and after installing some files it runs another custom program which kind of unpacks some previously installed files.

This unpacking program relies on some existing files being writable, which usually is the case. But on development machines these files are under version control and therefore write protected (have read-only attribute).

The unpacking program just doesn't unpack when these files are write protected (maybe it shows a warning in the console, but the console is hidden so one won't see this warning). And I can't change the code of this unpacking program.

So, I'm looking for a way to make these files writable with Inno Setup even though these files are not installed by Inno Setup.

How can I achieve this?


Solution

  • There's no built-in mechanism for that in Inno Setup.

    But you can do almost anything from Pascal Script using WinAPI. In this case, you want to use SetFileAttributes.

    For an example how to use SetFileAttributes from Inno Setup, see:
    Inno Setup Code section create hidden file