Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a folder in your exe file using Inno Setup Compiler

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

like image 697
fs_tigre Avatar asked Nov 14 '13 12:11

fs_tigre


Video Answer


2 Answers

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
like image 178
Deanna Avatar answered Oct 07 '22 00:10

Deanna


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 !

like image 36
anonimous Avatar answered Oct 07 '22 01:10

anonimous