user3027198
user3027198

Reputation: 303

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; 

Upvotes: 2

Views: 3659

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202594

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.

Upvotes: 2

Muhammad Omran
Muhammad Omran

Reputation: 4615

the answer is You CAN

  1. make windows display hidden files just for you to be able to see them
  2. with your files hidden as you want them inside the folder.
  3. when adding source folder and files step just add the folder (this wildcard *) normally, Inno setup won't add the hidden files. so add them separately.
  4. after you finsih all steps don't run the script and edit the code..

go to [Files] section:

[Files]
Source: "H:\tmp\sweetInstaller\installer.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "H:\tmp\sweetInstaller\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "H:\tmp\sweetInstaller\hidden_file1.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "H:\tmp\sweetInstaller\hidden_file2.bat"; DestDir: "{app}"; Flags: ignoreversion

AND insert Attribs: hidden; next to files you wish to hide just before Flags:

[Files]
Source: "H:\tmp\sweetInstaller\installer.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "H:\tmp\sweetInstaller\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "H:\tmp\sweetInstaller\hidden_file1.txt"; DestDir: "{app}"; Attribs: hidden; Flags: ignoreversion
Source: "H:\tmp\sweetInstaller\hidden_file2.bat"; DestDir: "{app}"; Attribs: hidden; Flags: ignoreversion

then you can run the script from the little green play button at the top bar to compile. and you're done ;)

Upvotes: 1

Related Questions