8
votes

I'm currently using Inno Setup Compiler to create an installer for Windows and everything is working fine except when I try to include a folder to the exe. In other words what I want is to be able to include a folder with two files in it, I want this folder to appear right where the .exe file is (C:\Program Files x86\appFolder) when the program is installed.

Inno has an option to add folders but for some reason when I select the folder with the two files I want, it compiles fine but when I actually install the program it actually adds the two files but not the folder.

I found the following line of code online and I used it but it actually included some folders that I didn't want. The problem I have with this line of code is that I don't fully understand it, I don't know where the folder path should be? What is Exlude: "Setup.iss,generated_images\"

Source: "*.*"; Excludes: "Setup.iss,generated_images\*"; DestDir: "{app}"; Flags:replacesameversion recursesubdirs

Can someone be so kind an explain this line of code?

Thanks

3
It should include all the files (*.*) from all subdirectories (recursesubdirs) from the location of the script excluding Setup.iss file and all the files from the generated_images subfolder. - TLama
I genrally store my script in a different folder so, if I add a absolute path and get rid of the exclude statement should work, right? Source:"*C:\Users\userName\Documents"; DestDir: "{app}"; Flags:replacesameversion recursesubdirs - fs_tigre
Sure, that Excludes parameter is there just for excluding. If you don't want to exclude anything from the Source directory (which can be of course absolute or relative path, but not just the path where the script is stored), don't use it. - TLama
I added an absolute path but it didn't work, it added the content inside the specified folder but not the folder itself. I moved my .iss script to the same folder as the .exe and used the Source: ".";... and it worked fine but its adding .o files and .txt files too, I know I could exluded them by adding the name for each one but they are a lot of them. Is there a way to say exlude all .txt files? Thanks a lot for your help. - fs_tigre
Here is what needs to be done to exclude all files with the same extension Source: "*.*"; Excludes: "scriptName.iss,*.txt*,*.o*"; DestDir: "{app}"; Flags:replacesameversion recursesubdirs Basically surround the extension with asterisks and separating each one with comas *.txt*, *.cpp* - fs_tigre

3 Answers

18
votes

From your comments (as you haven;t actually shown all the code you're talking about), I guess you are doing something like:

[Files]
Source: "blah.exe"; DestDir: "{app}"; Flags:replacesameversion
Source: "subfolder\*.*"; DestDir: "{app}"; Flags:replacesameversion

In this case, it is copying the contents of subfolder to {app}.

If you want to copy it and keep the sub directory, specify the directory itself:

[Files]
Source: "blah.exe"; DestDir: "{app}"; Flags: replacesameversion
Source: "subfolder"; DestDir: "{app}"; Flags: replacesameversion recursesubdirs

Or specify an explicit destination directory:

[Files]
Source: "blah.exe"; DestDir: "{app}"; Flags:replacesameversion
Source: "subfolder\*.*"; DestDir: "{app}\subfolder"; Flags:replacesameversion
5
votes

I was having a similar problem:

I have this folder among other things:

  • .\WorkFolder\MyEmptyFolder\

I want on installed system this:

  • .\PathToExe\Name.exe
  • .\PathToExe\MyEmptyFolder\

If folder is not empty it works, but sometimes i need empty folder.

I am using this line:

Source: .\WorkFolder\MyEmptyFolder\*; DestDir: {app}\MyEmptyFolder; Flags: ignoreversion recursesubdirs createallsubdirs

What i want script to do is (without need to re-write the script every time):

  • If folder is empty, then on installed the folder will be empty but exists
  • If folder has files and/or subfolders, then on installed the folder will exists and have that content

My problem is when it is empty, script ends with an error telling there is no files on it. It does not understand i want that folder and all what on it could be at that moment.

Thanks for the ideas, i try them and got the solution, here it is:

First ensure the folder will be created (if has no files with Files section it does not create it):

[Dirs]
Name: {app}\; Permissions: users-modify
Name: {group}\; Permissions: users-modify
Name: {app}\MyEmptyFolder\; Permissions: users-modify

Next edit the line on Files section to include "skipifsourcedoesntexist":

Source: .\WorkFolder\MyEmptyFolder\*; DestDir: {app}\MyEmptyFolder; Flags: ignoreversion recursesubdirs createallsubdirs skipifsourcedoesntexist

And it does what i want: Include such folder and all what is on it, no matter if folder is empty or not, script will not end with an error if it is empty.

How this works?

Easy trick: if folder is empty, file section line would fail and script will end with an error, but with skipifsourcedoesntexist it avoid that, but that would make such folder not exist, that is the reason why i add such folder on Dirs section, to ensure it is allways created.

Hope this helps other not getting mad !

0
votes

while making the setup file Inno SETUP....Click on new folder,click on the url,then click on edit and name the subfolder which you want to include in installation folder.