Copying hidden files in Inno Setup - 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;

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.

the answer is You CAN
make windows display hidden files just for you to be able to see them
with your files hidden as you want them inside the folder.
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.
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 ;)

Related

Inno Setup Using Variable in [icon] and [Registry] [duplicate]

This question already has an answer here:
Using global string script variable in Run or other section in Inno Setup
(1 answer)
Closed 11 months ago.
I am new to Inno Setup.
I have defined a few global variables in the [code] section.
I want to make use of it in [icons], [Files], and [Registry]
My start menu would depend on a few conditions. To simplify, I will derive where the shortcuts will be created and store the full path in the variable.
Assuming I have set the following Path in the code section.
CustomStartMenu:='C:\Users\Rajendra\AppData\Roaming\Microsoft\Windows\Start Menu\Programs';
I would like Inno Installer to create all the shortcuts based on the variable CustomStartMenu
[Icons]
Name: "{#CustomStartMenuPath}\MyApp"; Filename: "{app}\myApp.exe"; WorkingDir: "{app}"; IconFilename: "{app}\myapp.ico"; IconIndex: 0
Another Example
variable DotPaintAppPath
[Files]
Source: "c:\myplugin.exe"; DestDir: "{#DotPaintAppPath}\Effects\MyApp"; DestName: "MyApp.exe"; Flags: ignoreversion replacesameversion restartreplace;
Source: "c:\myapp1.exe"; DestDir: "{app}"; DestName: "myapp1.exe"; Flags: ignoreversion replacesameversion restartreplace;
Source: "c:\myapp2.exe"; DestDir: "{app}"; DestName: "myapp2.exe"; Flags: ignoreversion replacesameversion restartreplace;
You should use {code:...} constant.
Take icons for
[Icons]
Name: "{code:GetMyPath}\MyApp"; Filename: "{app}\myApp.exe"; WorkingDir: "{app}"; IconFilename: "{app}\myapp.ico"; IconIndex: 0
[code]
function GetMyPath(Param: String): string;
begin
Result := CustomStartMenu;
end;

InnoSetup: failed to remove temporary directory?

I have a function 'VerifySerialNumber' in SerialNumber.dll which depends on msvcr120.dll and msvcp120.dll:
function VerifySerialNumber(serialNumber:String):integer;
external 'VerifySerialNumber#files:SerialNumber.dll,msvcr120.dll,msvcp120.dll cdecl loadwithalteredsearchpath';
In [Files] section:
Source: "{tmp}\msvcp120.dll"; DestDir: {app}\Plugin; Flags: ignoreversion
Source: "{tmp}\msvcr120.dll"; DestDir: {app}\Plugin; Flags: ignoreversion
Source: "{tmp}\SerialNumber.dll"; DestDir: {app}\Plugin; Flags: ignoreversion
The problem is that the install log show "Failed to remove temporary directory: C:\Users\ADMINI~1\AppData\Local\Temp\is-SKE12.tmp" when the install finised. And there are two files, the msvcr120.dll and msvcp120.dll file, remained in the is-SKE12.tmp folder.
Any advice?

Inno Setup Make dirs and files read only

I'm new user in Inno Setup. My problem is that I have some folders and one file. I want to make a setup package to install all of them. Here is my code
[Files]
Source: "D:\POS CAD Standard\CAD\*"; DestDir: "C:\POS CAD Standard"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\POS CAD Standard\acad.lsp"; DestDir: "{userappdata}\Autodesk\AutoCAD 2014\R19.1\enu\support"; Flags: ignoreversion
[Dirs]
Name: "C:\POS CAD Standard"; Attribs:readonly hidden system; Permissions: users-readexec;Flags:
[Icons]
Name: "{group}\{cm:UninstallProgram,POS CAD Standard}"; Filename: "{uninstallexe}"
It works fine, but when I'm trying to setup to another PC my source file is not found, and I want to make some files (not folder) to be read only.
Use Attribs: readonly parameter.
It is supported both in the [Files] and [Dirs] sections.
Source: "D:\POS CAD Standard\CAD\*"; DestDir: "{sd}\POS CAD Standard"; \
Flags: ignoreversion recursesubdirs createallsubdirs; Attribs: readonly
Note that I've used the {sd} constant instead of hardcoding the C: drive (what is a bad practice).

Exclude files working not as expected?

I want to exclude 2 folders by default, unless a component is checked. I don't have all the files individually listed in the [Files] section, as some of them might be added/removed in the future, but there are 2 folders that I need to control.
Here's the code I have:
Source: "source\*"; DestDir: {app}; Excludes: "\plugins\api,\plugins\shared memory"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: "source\plugins\api\*"; DestDir: {app}; Flags: recursesubdirs createallsubdirs;
Source: "source\plugins\shared memory\*"; DestDir: {app}; Components: plugins_api; Flags: recursesubdirs createallsubdirs;
What I want:
Those subfolders (api and shared memory) should only be copied if
plugins_api is selected.
If the component plugins_api is not
checked, they should not be copied.
I'd rather avoid including
every file in the .iss file. It is not an option.
What I get with this code:
If the component is not checked, the folders are not copied. Ok.
If the component was checked, the folders are not copied. Not ok.
So it seems the exclude in the first line affects the other 2 lines. How can I avoid this?
2 points:
1) You only have the Components entry on one of the special folders.
2) The special folders, as you have them will be installing their contents direct into the {app} folder.
If you follow the folders in use:
Source: "source\plugins\api\*"; DestDir: {app};
Put contents of source\plugins\api\ in {app}
I expect you want something like:
Source: "source\plugins\api\*"; DestDir: {app}\plugins\api\; Components: plugins_api; Flags: recursesubdirs createallsubdirs;
Source: "source\plugins\shared memory\*"; DestDir: {app}\plugins\shared memory\; Components: plugins_api; Flags: recursesubdirs createallsubdirs;

Admin user always prehend initial user

Using an InnoSetup script (that seems to work fine under XP/Vista), i've a strange behavior under Seven RC:
here is the [Files] section:
[Files]
Source: *.ico; DestDir: {app}\bin; Flags: ignoreversion
Source: dist\*.*; DestDir: {app}\bin; Flags: ignoreversion
Source: catalog\*.*; DestDir: {userappdata}\JetWorksheet\catalog; Flags: recursesubdirs createallsubdirs onlyifdoesntexist uninsneveruninstall
Source: wizards\*.*; DestDir: {userappdata}\JetWorksheet\wizards; Flags: recursesubdirs createallsubdirs onlyifdoesntexist uninsneveruninstall
Source: images\*.*; DestDir: {userdocs}\JetWorksheet\images; Flags: recursesubdirs createallsubdirs
Source: wordlists\*.*; DestDir: {userdocs}\JetWorksheet\wordlists; Flags: recursesubdirs createallsubdirs
The problem is:
In place of using the {userappdata} of the user that started the setup, all the data goes to the "Admin" directories...
I'm surely missing somethings...
You should either use PrivilegesRequired=lowest so your Setup doesnt elevate, or you should place the default user files in a common directory during installation, and then have your application copy them to the user area on startup.

Resources