2

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; 
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user3027198
  • 183
  • 3
  • 11
  • You'll need to be more specific. Inno Setup doesn't care whether a file is hidden or not, and they can be removed and replaced just like any other file. What **specifically** are you trying to do? Please include the code from your install script with your [edit]. We can't help you if you don't clearly explain the problem. – Ken White Dec 02 '15 at 19:01
  • If files within **folder** are hidden - nothing happens ) – user3027198 Dec 02 '15 at 19:23
  • `{src}` is the path to the **source** files (the files within your setup). Why would you need it to be hidden in the **source**? (You've clearly seen it, since you added it to the source yourself.) Your `[Files]` entry clearly says the files come from `{src}\folder\`, but you're trying to load from `{src}\file.txt`. And please provide additional information to your question in the question itself, not in comments. – Ken White Dec 02 '15 at 19:28
  • this script is all information I can possibly provide =( – user3027198 Dec 02 '15 at 19:37
  • why it's not working when the files are hidden? – user3027198 Dec 02 '15 at 19:40
  • I've told you. Your file is in a different location than where you're trying to open it from, according to the script source you've posted. Read my last comment again more carefully. If that's not the problem, then your post does not contain the relevant information. – Ken White Dec 02 '15 at 19:44
  • @KenWhite The problem is that the `Source` parameter does not select hidden files. The code is irrelevant to the problem. I've removed it, not to confuse others. See [my answer](http://stackoverflow.com/a/34051706/850848). – Martin Prikryl Dec 02 '15 at 19:58
  • @Martin: Thanks for the feedback. The edit I requested to add the script was posted to the question in it's original form, which contained *zero* information regarding the script itself, the way the file was being accessed, and a very vague description of the issue. Knowing where the file is located when the attempt to access it fails is quite relevant. :-) – Ken White Dec 02 '15 at 21:47

2 Answers2

2

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 Inno Setup: copy folder, subfolders and files recursively in Code section.


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

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • It seems that the procedure DirectoryCopy, will only work for copying files when the source and destination are on the same machine, which is usually not the case. What is needed is that the source folder which contains the hidden files, should be extracted from the setup.exe ( the installer setup file which is distributed to end users for the installation ). This does not seem to be happening, maybe am missing something. – Sanjay Karia May 07 '18 at 06:42
  • This question is about *"copying hidden **external** files"*. Your comment is thus about a different problem, hence for a separate question, what I can see that you have posted: [Installing hidden files using Inno Setup](https://stackoverflow.com/q/50209033/850848). – Martin Prikryl May 07 '18 at 17:18
2

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 ;)

Biskrem Muhammad
  • 4,074
  • 3
  • 31
  • 38