inno-setup

Copying hidden external files in Inno Setup


How to use copy hidden external files in Inno Setup? Not to make a file hidden, but to work with hidden files. Because for now: the hidden files are being ignored

Any help? Thanks )

[Files]
Source: "{src}\folder\*"; DestDir: "{app}"; \
    Flags: skipifsourcedoesntexist external ignoreversion recursesubdirs createallsubdirs; 

Solution

  • Note for readers: This question is about niche "external" files. For a question about regular installation files, see Installing hidden files using Inno Setup.


    When you select files in [Files] section entry using a wildcard, Inno Setup installer explicitly skips hidden files.

    You cannot do anything about it.

    See RecurseExternalCopyFiles function in Projects\Install.pas, particularly this part:

    if SourceIsWildcard then begin
      if FindData.dwFileAttributes and FILE_ATTRIBUTE_HIDDEN <> 0 then
        Continue; // <-- Skip hidden files, comment by @MartinPrikryl
      FileName := FindData.cFileName;
    end
    else
      FileName := SearchWildcard; // use the case specified in the script
    

    (This is for external files, as that's what you use. But for compile-time files, it's the same. See BuildFileList in Compile.pas).


    All you can do, is to implement the installation in [Code] script yourself, instead of using the [Files] section.

    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if CurStep = ssInstall then
      begin
        Log('Installing files');
        DirectoryCopy(ExpandConstant('{src}\folder'), ExpandConstant('{app}'));
      end;
    end;
    

    For implementation of DirectoryCopy, see my answer to question Copy folder, subfolders and files recursively in Inno Setup Code section.


    For compile-time files (without external flag), you can generate list of [Files] entries using a preprocessor function FindFirst.