Inno setup create folder for image files - inno-setup

I would like to create a folder on C drive with Inno Setup C:\A A Card Images
and I am assuming I can use the [Files]Source:"Path to Images" DestDir: "{app}"; Flags: ignoreversion
[Dirs]
Name: "C:\A A Card Images" This is what I have tried but it tells me File exists
So it seems obvious to me that I need to create the folder before I try to add Image files to the folder
So do I use [Dirs] or [Files] to create the folder?
And using DestDir: "{app}"; Flags: ignoreversion to load the Images into the folder seems wrong
Because I do not want the Images in the DestDir I want them in C:\A A Card Images

To create a new directory during the install, use the [Dirs] section. The Name is used to specify the location. Using "{app}\foldername" means to create the directory below the application's directory. To create it somewhere else, specify the full path to the directory.
[Dirs]
Name: "C:\Whatever"
Use the [Files] section to indicate the files you want to install, and the location of those files. You use DestDir to specify that location.
Note that users may not be pleased if you create directories and install files in non-standard locations. There are valid reasons that those standard locations exist. I personally don't like it when applications clutter my drive in places they shouldn't be using.

Related

How to recursivelly include folder/files using a wildcard in Inno Setup

I want to include language resource files from our build into our installers. The language resource files all have the same name, but reside in different sub-folders (one per locale), like this:
\Release
\bin
\es-MX
Localization.resources.dll
\fr-CA
Localization.resources.dll
etc.
In my [Files] section, I thought perhaps I might be able to do this (note the position of the asterisk):
Source: "..\\source\\Libraries\\Localization\\bin\\Release\\*\\Localization.resources.dll"; \
DestDir: "{app}\\MyApp"; Flags: ignoreversion recursesubdirs
Unfortunately, Inno Setup blows up, complaining that it can't find any files:
Compiler Error!
Line 129: No files found matching "C:\Development\HT\Installers\..\source\Libraries\Localization\bin\Release\*\Localization.resources.dll"
I would like Inno Setup to look for any sub-folder (hence the *) containing a file named Localization.resources.dll and upon installation, create a language directory with the same name (based on what is found via the wildcard) and copy the file to that folder, doing so for each folder that matches the criteria.
Essentially, I want to end up with this:
..
\MyApp
\es-MX
Localization.resources.dll
\fr-CA
Localization.resources.dll
In case it isn't obvious, I would prefer not to explicitly add the source and destination folder names, because we will be adding more languages/locales in the future, and I would like Inno Setup to automatically pick up any new language folders/files we create without having to change the installer source.
Is this possible?
Just use the recursesubdirs flag with a root path to a tree and the Localization.resources.dll filename. It will automatically do what you want: find all Localization.resources.dll files in the tree and install them to their respective subfolders:
Source: "..\source\Libraries\Localization\bin\Release\Localization.resources.dll"; \
DestDir: "{app}\MyApp"; Flags: ignoreversion recursesubdirs
As documented (emphasis mine):
recursesubdirs
Instructs the compiler or Setup to also search for the Source filename/wildcard in subdirectories under the Source directory.
Other possible approaches:
Generate the Files section using a preprocessor.
For a similar tasks, see:
Inno Setup - Recurse sub directories without creating those same sub directories
Generating Inno Setup file flags programmatically
Inno Setup: Dynamically add a component for all files in a folder and its subfolders
Generate the Files section using an external scripting language (with better functionality then Inno Setup preprocessor) and invoke it using the Exec preprocessor function. E.g. using PowerShell.

Extract multiple files from installer before installation begins in Inno Setup

I have few SQL script files which have to run before installation begin. The reason is if SQL scripts run successfully only, I want to do the installation.
If the SQL scripts need to run after the installation, I can copy the files to {app} path and run the files from there. But the requirement is run the files before installation begins. I am confused. What is the best way of doing it?
Say for example if it is a single file I can put it under Files section and can use ExtractTemporaryFile('FileName');
But as I mentioned, I have many files (in SQLSCRIPTS folder). What is the better way? (One solution is I can make it as a single file by zipping it and then unzip it)
[Files]
Source: "C:\\SQLSCRIPTS\\*"; DestDir: "{app}"; Flags: dontcopy
To extract multiple files from installer, use the ExtractTemporaryFiles, like:
ExtractTemporaryFiles('*.sql');

Install the main application executable file to subfolder with Inno Setup Studio

I was using Inno Setup QuickStart Pack 5.5.6 and it was perfect.
I installed Inno 5.5.8 QuickStart Pack 5.5.8 and I'm having some problem.
If I start Inno Setup I can select appname, company and Ii can select path of the program and program exe file, so look this screen:
like you can see I selected the main .exe in \Binaries\Win32\ so it is located not in main folder of the program but in a sub-folder.
Now this is the code that I have
Inno Script studio automatically write the wrong exe path, it is not the main folder of the program but like I said already it is in \Binaries\Win32\.
But why it did this? I worked with Inno Setup QuickStart pack 5.5.6 and I never seen this problem, the correct path was correct also if the exe was in some sub-folder.
You have these two entries in the [Files] section.
[Files]
Source: "C:\temp\Life Is Strange Episode 5\Binaries\Win32\LifeIsStrange.exe"; \
DestDir: "{app}"; Flags: ignoreversion
Source: "C:\temp\Life Is Strange Episode 5\*"; \
DestDir: "{app}"; Flags: ignoreversion recursesudirs createallsubdirs
This does not make any sense. The entries overlap.
It seems you believe that by selecting the directory C:\temp\Life Is Strange Episode 5 in the "Other application files" setting you somehow miraculously define a mapping between the C:\temp\Life Is Strange Episode 5 and the {app} that should make Inno Setup Studio know that when you select the main application file C:\temp\Life Is Strange Episode 5\Binaries\Win32\LifeIsStrange.exe it should go to {app}\Binaries\Win32. It won't. The entries are not related to each other in any way.
So, the first entry will install the LifeIsStrange.exe directly to {app}.
The second entry will install a whole directory tree, including the LifeIsStrange.exe.
So you end up with LifeIsStrange.exe both in the {app} and the {app}\Binaries\Win32.
But the icon will point to {app}\LifeIsStrange.exe.
I believe the Inno Setup Studio does what you asked it to do.
If you want it to do something else, you have to set up things differently. Though I'm not sure the Inno Setup Studio allows you to install the main application executable anywhere else, but to the {app}.
To do what you ask for, you probably have to edit the .iss manually to be like:
[Files]
Source: "C:\temp\Life Is Strange Episode 5\*"; DestDir: "{app}"; \
Flags: ignoreversion recursesudirs createallsubdirs
[Icons]
Name: "{group}\{#MyAppName}"; FileName: "{app}\Binaries\Win32\LifeIsStrange.exe"

How to create an installer using Inno Setup which extracts the contents of a .rar archive?

I want to create an installer in Inno Setup which extracts the content of pre created Data.rar archive. I mean it should treat the contents of the rar archive as files and folders of application.
A generic way to use an external extraction utility with Inno Setup:
create the archive
embed the archive to the installer
embed a tool that can extract the archive to the installer
make the installer extract the archive and the tool to a temporary location on target machine - {tmp}
make the installer run the tool to extract the archive
[Files]
Source: "UnRAR.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "Data.rar"; DestDir: "{tmp}"; Flags: deleteafterinstall nocompression
[Run]
Filename: "{tmp}\UnRAR.exe"; Parameters: "x ""{tmp}\Data.rar"" ""{app}"""
If you want to present a progress of the decompression, you will have to parse the UnRAR output. For an example (on Arc), see How to add .arc decompression to Inno Setup?
Or use UnRAR.dll, similarly as unarc.dll is used in Inno Setup - How to add cancel button to decompressing page?
Note that the UnRAR.exe tool is free and can be used for these purposes. An extract from its license.txt:
The UnRAR utility may be freely distributed. It is allowed
to distribute UnRAR inside of other software packages.

How can I extract an embedded archive to disk during the installation process

I have an embedded 7Zip archive in my setup script.
Is there a "native" way of extracting the contents to a target folder?
If not any hints on how this could be achieved?
Updated with my implementation. Thanks for the hint TLama
[Files]
Source: "Documentation.7zip"; DestDir: "{tmp}"
Source: "7za.exe"; DestDir: "{tmp}"
[Run]
Filename: "{tmp}\7za.exe"; Parameters: "x -o""{app}"" ""{tmp}\Documentation.7zip"""; Flags: runhidden; Description: "{cm:InstallingDocumentation}"; StatusMsg: "{cm:InstallingDocumentationStatus}"
[CustomMessages]
en.InstallingDocumentation=Documentation Files
en.InstallingDocumentationStatus=Installing Documentation Files. This may take several minutes...
No, there is no native way to extract 7zip files from InnoSetup installer. However, you can get a copy of 7zip library, which is redistributable and call it from InnoSetup script's code section.
Inno doesn't have any native method of extracting files from anything other than it's own archives (which normally compress better than 7Zip).
Inno Setup can however use wildcards for including files to install:
[Files]
Source: "Documentation\*.*"; DestDir: "{app}/Documentation/";
If you have many small files, using the solidcompression flag will improve compression performance and size.

Resources