Recursive setting of folder permissions with InnoSetup - inno-setup

I have a folder tree that I copy to C:\ProgramData The software that I am installing (don't blame me for this, I did not architect, write or design it) requires full control for everyone for this data.
So I put the following line in [Files] sectionL
Source: "C:\ProgramData\PFPS\MapDataServer\*"; DestDir: "C:\ProgramData\PFPS\FalconViewCommand"; Flags: ignoreversion createallsubdirs recursesubdirs; Permissions: everyone-full; Excludes: "*.LDF"
yes, this does give everyone full control of each individual file, but the program needs to create files and the folder permissions (directory) are not set for everyone.
I tried to add a [Dirs] section but that did not work:
[Dirs]
Name: "C:\ProgramData\PFPS\FalconViewCommand"; Flags: uninsalwaysuninstall; Permissions: everyone-full
What do the guru's say?

This works for me:
[Dirs]
Name:"{app}\"; Permissions:everyone-modify

What I have been doing is the following RUN at the end, I was finding that the Dirs was not working (yes, I always do a full unistall, when testing install scripts), otherwise how do you know what will happen when the product ships?
I agree with you about {commonappdata} but I am trying to remove randomness till I get to the bottom of the issue.
Here is what I have been trying:
[Run]
Filename: "C:\Windows\System32\icacls.exe"; Parameters: "C:\ProgramData\PFPS\FalconViewCommand /grant:r Users:(OI)(CI)F"; WorkingDir: "{tmp}"; Description: "Changing Directory Permissions"; StatusMsg: "Changing Directory Permissions"

Related

Shortcut to a folder on desktop in Inno Setup

I have made an exe file with Python and now I am trying to make an installer for it. I want to add a command in Inno Setup so after the installation it creates a shortcut to a folder in the installed directory (program folder/mixes). I want the shortcut to be on the desktop. I understand that you do it in the [Icons] sections but the examples I found were making a shortcut to an exe file but I want to make a shortcut to a folder. How do I do that? below is the Inno code:
#define MyAppName "Blender"
#define MyAppVersion "1.5"
#define MyAppExeName "Blender.exe"
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={autopf}\Cybercrete
DisableProgramGroupPage=yes
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; \
GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Dirs]
Name: "{app}"; Permissions: users-full
[Files]
Source: "C:\CyberCrete\Ver 1.5\Output\Blender\{#MyAppExeName}"; DestDir: "{app}"; \
Flags: ignoreversion
...
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Tasks: desktopicon
Name: "{commondesktop}\Setup"; Filename: "{app}\Setup.exe"; \
WorkingDir: "{pf}\Program"; IconFilename: "{app}\Setup.ico"
[Run]
Filename: "{app}\{#MyAppExeName}"; \
Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \
Flags: nowait postinstall skipifsilent`
I read many forums but they are about making shortcuts to exe files not folders.
Creating a shortcut to a folder is the same as creating shortcut to a file. Just use the path to the folder as the shortcut target:
[Icons]
Name: "{autodesktop}\My Folder"; Filename: "{app}\My Documents"
Though indeed, you should not store user's documents into app installation folder. Use user's Documents folder or application data folder.
Granting users full permissions to the program's installation folder is an equally bad practice.
Seems like this link explains everything you should need to know about creating shortcuts.
My program makes PDF files as output in a folder called "mixes". I
want to make it easier for the users to access the folder, that's why
I want to make a shortcut to the result folder.
I would highly recommend not to make the output folder in a relative folder in the program files (i.e. in a folder that is located in a location that is based on where the program is installed). This is both not easily found and will often need Admin permissions to write to a folder stored there.
I would recommend placing the folder in Documents (assuming this is Windows) or in AppData, which would make the folder both more easily accessible and will not run into permission issues.

How to get current setup directory for the script section?

Under the [Run] section I want to change the working directory to the directory from which the installer was executed. For example, if the setup was executed from the Desktop, I want the working directory to point to the Desktop:
Filename: "{app}\setup.exe"; WorkingDir: "{app}"; MinVersion: 0.0,6.0; Flags: skipifsilent
Use the {src} constant. The documentation describes it as:
{src}
The directory in which the Setup files are located. For example: If
you used {src}\MYPROG.EXE on an entry and the user is installing from
"S:\", Setup will translate it to "S:\MYPROG.EXE".
In your case you can use it like:
[Run]
Filename: "{app}\setup.exe"; WorkingDir: "{src}"; MinVersion: 0.0,6.0; Flags: skipifsilent

Inno Setup can't handle Source path with space

my application has this directory that I need to include in the install package:
bin\Win Files\*
So, in the [Files] section, I have this line:
Source: "bin\Win Files\*"; DestDir: "{app}\bin\Win Files"; Flags: ignoreversion; Permissions: everyone-modify
But at compile time, it keeps saying it can't find that directory due to space in the path, the exact error message is:
No files found matching "C:\dev\packages\MyApp\bin\Win Files\*"
I've tried the following, all failed:
Source: """bin\Win Files\*"""
Source: "\"bin\Win Files\*\""
Source: '"bin\Win Files\*"'
That directory has to be named like that, so what should I do?
I use this:
[Files]
; Main application
Source: "{#SourceDir}\*"; DestDir: "{app}\"; Flags: recursesubdirs ignoreversion;
to copy all my files in one go to the installer. Note the recursesubdirs flag. I think spaces in the path (referenced here in the variable named SourceDir) are not actually a problem here.
This is due to the misunderstanding about the directory/file structure scanning mechanism in Inno Setup.
First of all, as #Martin Prikryl pointed out, one can include path that has space in it.
I think the following two rules are the key to this issue:
One cannot specify a folder that has no standalone files (e.g. empty folder or a folder that only has sub-directories). In my case: I have the following file structure per this question:
bin\Win Files\Libs\
bin\Win Files\Plugins\
So Source: "bin\Win Files\*"; will fail. If there is at least one standalone file under the "bin\Win Files\" folder, then the source line will work.
Inno Setup requires each folder be explicitly specified in the [Files] section as below:
Source: "bin\Win Files\Libs\*"; DestDir: "{app}\bin\Win Files\Libs";
Flags: ignoreversion; Permissions: everyone-modify
Source: "bin\Win Files\Plugins\*"; DestDir: "{app}\bin\Win Files\Plugins";
Flags: ignoreversion; Permissions: everyone-modify
as Source: "bin\Win Files\*"; will NOT include the sub-directories automatically, it is only used to include the standalone files under the bin\Win Files\ folder.

Inno Setup is not including any of indicated files in destination folder

This is the first time I've used an installer program other than Access Developer Extensions. I have couple of MS Access files I'm trying to have installed into the user's AppData\Local folder. The only thing it will seem to do is put two files in that folder: unins000.exe and unins000.dat. It seems to ignore the files I want put in there, although when I compile it's definitely including them in the Setup.exe file. Here is the script - can someone tell me what could be wrong here? It doesn't seem to matter if the destination folder or files exist or not - I get the same result.
; -- LEAP.iss --
[Setup]
AppName=LEAP
AppVersion=1.1
DefaultDirName={localappdata}\LEAP
DefaultGroupName=LEAP
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Output
[Files]
Source: "China.accdb"; DestDir: "{localappdata}"; DestName: "China.accdr"
Source: "Replica of China_be.mdb"; DestDir: "{localappdata}"
[Icons]
Name: "{group}\LEAP"; Filename: "{localappdata}\China.accdr"
Name: "{userdesktop}\LEAP"; Filename: "{localappdata}\China.accdr"
You want to replace {localappdata} with {app} in the [Files] and [Icons] sections. The {app} constant is defined once the user selects the install location on the "Select Destination Location" wizard page. Your end-users might not appreciate that you've allow them to choose a location to install your program, only to find out that you've actually hard-coded that location in the installer.
If you don't want them to choose a location, then set DisableDirPage=true in [Setup].
You should also establish an AppID value in [Setup].

Make folder hidden after Inno Setup installs it

My application has a folder of files that are all marked as "hidden" (including the folder itself). However, Inno Setup won't copy them for installation unless I remove the "hidden" attribute first.
Fair enough, but is there a way to make Inno Setup mark the installed folder as "hidden" after it finishes setup on my end-user's machine?
Thanks.
See the Attribs parameter for entries in the [Dirs] section.
[Dirs]
Name: "{app}\blah"; Attribs: hidden;
Note that this won't really stop people from seeing it, just make it look like you have something to hide.
First of all, ensure that ONLY the directory is hidden, and not the subdirectory. Say its name is srcHiddenDir.
Now, create another directory dstHiddenDir, but dont make it hidden now. But it should be empty.
Then, open the settings.json, and replace all the occurrences of srcHiddenDir with dstHiddenDir.
Now, Make it ready to copy files as usual. In one part of the code, you will get:
[Files]
Source: "wherethewholecodeis\phpdesktop\phpdesktop-chrome.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "wherethewholecodeis\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "wherethewholecodeis\*srcHiddenDir*\*"; DestDir: "{app}\*dstHiddenDir*"; Attribs:hidden; Flags: ignoreversion recursesubdirs createallsubdirs
Then, you need to write:
[Dirs]
Name: {app}\dstHiddenDir; Attribs:hidden;
Name: {app}\dstHiddenDir\application; Attribs:hidden;
Name: {app}\dstHiddenDir\database; Attribs:hidden;
Name: {app}\dstHiddenDir\css; Attribs:hidden;
....
...and all the subdirectories you want to hide, just for more safety. But Note those subdirectories should be genuine, and there in the source/destination. Else, when you run the setup, error will show that these directories dont exist.
Now, compile the program.
Hope this helps.

Resources