Copying hidden files in Inno Setup

前端 未结 2 903
我寻月下人不归
我寻月下人不归 2020-12-20 02:09

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

An

相关标签:
2条回答
  • 2020-12-20 02:15

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

    0 讨论(0)
  • 2020-12-20 02:26

    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.

    0 讨论(0)
提交回复
热议问题