We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Selectable "Variants" of files with the same name

I'm trying to create an installer that contains files with the same name, but their contents are different. The preferred theme is BlackSurface. The installer should request the user to accept the EULA as per usual, and then prompt them to select which variant of the files they would like to install. The installer is only file-based and doesn't include a .exe or other runnable programs. Users shouldn't have the option to select more than one variant of the files to install either. I've tried searching through the forums and the documentation, but I don't know how to phrase the search or what I'm looking for exactly. Please advise
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Selectable "Variants" of files with the same name

Hello and welcome to Advanced Installer forums,

Since it is not possible to add two files with the same name in the same folder (from the "Files and Folders" page), we will have to apply a little hack in order to achieve what you want. Here is how you can proceed in order to achieve what you want:

Before we begin: let's work on an example, as this will help you understand better. Let's consider we have two text files, both named text.txt. Both files contain different content.

- please go to "Files and Folders" page

- right click on the "Application Folder" --> "New Folder" --> "Regular"

- please repeat the above step once again, to add one more sub-folder

- now please add your files in the first, respectively the second folder

- right click on the first folder --> "Properties". Here, please check the "Install folder content into the parent folder" option. This folder only works as a decoy, the content of it will actually be installed in the main folder
NewFolder.png
NewFolder.png (150.47 KiB) Viewed 10640 times
- please repeat the above step for the second folder as well

- now please go to "Organization" page. Here, a component is created for each of our text files. You can click on any of them and then condition there installation as per your needs
Organization.png
Organization.png (124.59 KiB) Viewed 10640 times
Hope this helps.

Also, please let me know if anything is not clear or if there is anything else I could help you with and I will be glad to assist.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Re: Selectable "Variants" of files with the same name

Thank you for the handy guide Catalin. I'm trying it at the moment, and I'll let you know if I run into any unexpected hickups.
Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Re: Selectable "Variants" of files with the same name

I seem to have run into my next hickup, though I'm definitely making great steps in the right direction.

Using your example, I've created all the subfolders necessary to where I want the files to install to and created two subfolders in that folder, setting both folder properties to install to the parent folder.

Following that, I created another feature, and set the second folder in that feature as a component. Now I have both of the "packages" displaying in the installer as intended, completely separate from one another.

The conditions are my next challenge. I'm not well versed with how the conditions work. Would you mind supplying me with a sample or instructions to set it that if one "package" is selected to be installed, that any and all other packages cannot be selected for install?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Selectable "Variants" of files with the same name

Hello,

You are always welcome, I am glad the information was helpful for you.

From what I understand, you now have two features, each containing the components assigned to your files, am I right?
Would you mind supplying me with a sample or instructions to set it that if one "package" is selected to be installed, that any and all other packages cannot be selected for install?
I guess that here you want to let the user choose which one of the features he wants to install. If so, here is how I would proceed:

Based on the example give in my first thread, let's consider:

1. In "Organization" page, we will have two features (each corresponding to our text files), defined as such:
Features.png
Features.png (16.17 KiB) Viewed 10625 times
- first of all, I would create a new dialog in which the user can select which feature he wants installed (either the feature containing the first text file or the one containing the second one). To do so, you can go to "Dialogs" page, click on "WelcomeDlg" and then press the "New Dialog" button from the ribbon.

-- on the newly created dialog, you can add two CheckBox controls (by pressing the "Controls Toolbox" button from the toolbar), as such:
FirstFeatureCheckbox.png
FirstFeatureCheckbox.png (189.61 KiB) Viewed 10625 times
SecondFeatureCheckbox.png
SecondFeatureCheckbox.png (172.97 KiB) Viewed 10625 times
- now, what we can do is to condition our features to be installed based on the state of the checkbox control. For instance, if the first checkbox is checked, we install the first feature, if the second one is checked, we install the second feature. Here is how this can be achieved:
InstallFirstFeature.png
InstallFirstFeature.png (120.41 KiB) Viewed 10625 times
InstallSecondFeature.png
InstallSecondFeature.png (122.79 KiB) Viewed 10625 times

A quick explanation: Pretty much all controls have a property assigned to them. The checkbox control makes no exception to this rule. The property that is assigned stores the state of the checkbox. For instance, by default (it can be changed), the property that is assigned to a checkbox control has the following values:

1. CHECKBOX_PROPERTY = "CheckBox" ---> if the checkbox is checked

2. CHECKBOX_PROPERTY = "" (empty string) ---> if the checkbox is unchecked

Based on the above explanation, hopefully the condition from the "Installation Behavior" section makes sense.

Now, in addition to that, you mentioned that you wanted to now allow the installation of a feature if the other one is selected. This can be achieved through a control condition applied to the checkbox controls. Here is how this can be achieved:
FirstFeatureCC.png
FirstFeatureCC.png (183.6 KiB) Viewed 10625 times
SecondFeatureCC.png
SecondFeatureCC.png (194.35 KiB) Viewed 10625 times
As you can see, here we control the state of one feature based on the other. For instance, if the first checkbox is checked ==> the first feature will be installed ==> the second checkbox will be disabled ==> the second feature will not be installed. The same goes the other way around.

Additionally, for your reference, please find attached a sample project which you can build and see how it behaves.
SampleProject.zip
(4.66 KiB) Downloaded 322 times
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Re: Selectable "Variants" of files with the same name

Hi there Catalin,

The instructions you sent worked exactly as intended. I ended up using radio groups and buttons, and setting their value to make them easily distinguishable for their "installed If:" instruction. I got exactly what I was hoping for. I can't forsee any other issues related to this specific topic, so you're welcome to close it or mark it as solved, if that's applicable on this forum.

Thank you again for the assist.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Selectable "Variants" of files with the same name

Hello,

You are always welcome.

I am glad you got this working.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Re: Selectable "Variants" of files with the same name

Hi Catalin,

Apologies for revisiting an old thread. I've expanded on my installer by quite some margin, but now I'm struggling with setting the conditions more than one radio button. Is there a way for a specific feature to be installed with conditions that would resemble this:

RADIOBUTTONGROUP_1_PROP = "RadioButton_1" + RADIOBUTTONGROUP_2_PROP = "RadioButton_1"

and the installer only installs a specific feature?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Selectable "Variants" of files with the same name

Hello,

First of all, please accept my apologies for the delayed reply (I was away for a while - for a conference - and I did not have access to the forum)
Apologies for revisiting an old thread.
No worries for that.
but now I'm struggling with setting the conditions more than one radio button
In order to achieve this, you can use the "AND" operator. For instance, your condition can look like this:

Code: Select all

RADIOBUTTONGROUP_1_PROP = "RadioButton_1" AND RADIOBUTTONGROUP_2_PROP = "RadioButton_1"
Additionally, you can also use the "OR" operator. Basically:

- AND operator means that both (or all) conditions have to be met

- OR means that at least one condition has to be met

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Re: Selectable "Variants" of files with the same name

Worked perfectly. Thank you so much. And no problem at all regarding the delays :)
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Selectable "Variants" of files with the same name

You are always welcome.

I am really glad I could help.

Just let me know if you have any other questions and I will gladly assist.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Navsigda
Posts: 7
Joined: Sat Oct 19, 2019 12:17 am

Re: Selectable "Variants" of files with the same name

It seems we're on to the next section of my installer. Your help has been invaluable thus far. I've read through the how-to's, but I can't seem to find clear instructions to do what I need to. After finding out that I can use PowerShell scripts to make my life quite a bit easier, I've decided to take a different approach. Previously, I've had to make several iterations of the same files to offer a degree of variance using radio buttons. Using PowerShell scripts, could I have the installer place the predefined files in the directory, and depending on which radio button the user chooses, have it run a certain set of PowerShell scripts from embedded files instead of in-line? That way I can actively make the edits to files and only have to worry about scripting changes, as opposed to creating several variants of the same files?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Selectable "Variants" of files with the same name

Hello,

First of all, please accept my apologies for the delayed reply. I currently came back from a conference and had a lot of catching up to do, therefore the pretty delayed replies.

In what regards your question, there are some things I would like to clear so I can be sure I correctly understand your scenario. So basically you want to have some files copied on the machine and then, based on some radio buttons selection, execute some PowerShell scripts upon those files?

If that is the case, please allow me to explain few things:

First of all, as you could notice in the "Custom Actions" page, there are two main installation stages - the "Wizard Dialogs Stage" and the "Install Execution Stage". The files are copied on the target machine during the "Install Execution Stage" --> "Add resources" action group.

The problem here would be the fact that this happens after the Dialogs stage (where the dialogs are spawned and where you can make the radio button selection).

Fortunately, we can work this around by using our predefined support for "Temporary Files". Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process.

With that being said, a solution for your scenario would be to add your files as temporary files. This way, the files will be copied on the target machine during the "CostFinalize" standard action (which takes place before the dialogs are spawned. Please have a look on the following screenshots for more information about this:
CostFinalize.png
CostFinalize.png (120.56 KiB) Viewed 9394 times
UserSelection.png
UserSelection.png (223.08 KiB) Viewed 9394 times
That that hopefully things are a bit cleared now, let's talk about the PowerShell scripts. Basically, pretty much every custom action can be conditioned. All you have to do here is to go to "Custom Actions" page --> select your custom action --> go to "Execution Stage Condition" and insert your condition there. Here is how it looks like:
CustomAction.png
CustomAction.png (159.19 KiB) Viewed 9394 times
What is underlined with the red line is the default condition that is added. What comes after is your custom condition. In the example, I have used the "AND" operator, but you can also use another one (i.e. the "OR" operator).

In what regards the developing of the condition based on the radio button controls, I think we have previously discussed this in the above threads. If there is anything that is unclear there, please let me know and I will be glad to explain it.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”