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!

mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Features with Radio Buttons

Hello again Catalin,

I have really appreciated your help over the last few day. I have ran into one more thing that I do not understand fully after reading the guides...

I am trying to install features using radio buttons. I have two files with the EXACT same file name, but only one needs to be installed by the user depending on which one they want to use. Where can I store these files temporarily before the user picks one to install? They cannot go in the same directory because of them having the same file name, but I also do not want both sitting on the machine after install.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Features with Radio Buttons

Hello,
I have really appreciated your help over the last few day.
I am really glad I could help!

Most of what you want to achieve is possible with our predefined support. Please allow me to explain how this can be achieved:

Let's start with the beginning. In the "Files and Folders" page, please create two folders under the "Temporary" folder.
TEMP.png
TEMP.png (47.36 KiB) Viewed 11533 times

Now please click on the first folder --> "Add Temporary Files" button from the ribbon. Now please add the first version of your file.

Now please click on the second folder --> "Add Temporary Files" button from the ribbon. Now please add the second version of your file.

Now that the files are added, if you double click on the file, you will notice that it has a property assigned to it. This property stores its path (we will need this a bit later).
SampleOne.png
SampleOne.png (70.89 KiB) Viewed 11533 times
SampleTwo.png
SampleTwo.png (73.75 KiB) Viewed 11533 times

You have mentioned that you want the files to be installed based on a RadioButton control. With that being said, we need to add a "Radio Button Group" control to one of our dialogs. To do so, please:

- go to "Dialogs" page, select one of your dialogs (e.g. "WelcomeDlg")

- in the ribbon, please click on the "Controls Toolbox" button

- from the list, select the "Radio Button Group" control and add it to your dialog.

- now, if we click on the control, we will see that it has a property assigned to it as well. This property stores the state of the control (e.g. which radio button was selected)
RadioButton.png
RadioButton.png (164.43 KiB) Viewed 11533 times

If you click on each radio button, you can see the values that the "RADIOBUTTONGROUP_1_PROP" property can take:

RadioButton_1

respectively

RadioButotn_2

RadioButtonVal.png
RadioButtonVal.png (151.15 KiB) Viewed 11533 times

Now, normally, we should achieve what we want through a "File Copy/Move" operation. However, this is not possible, because the destination file name can't be the same for two operations.
FileCopy.png
FileCopy.png (196.38 KiB) Viewed 11533 times

In the above screenshot you can see how a "File Copy/Move" operation looks like. As you can see, it has, as parameters, a source file and a destination file. The destination file name is actually the name of the copied file.

As you can imagine, in our scenario, we would need two such operations. The thing here is that, unfortunately, the destination name can be the same for two operations.

With that being said, we can not use our predefined support for this task. However, this is possible through a custom approach (a custom action) - e.g. a script.

For this, we can use a script (e.g. PowerShell, VBScript) that will copy our file from the temporary location to our application directory (APPDIR) based on the radio button selection. Here is how the script could look like:

Code: Select all

# Block for declaring the script parameters.
Param($appDir, $sampleOne, $sampleTwo, $radioButton)

# Your code goes here.

# based on the radio button selection, we copy our files from the temporary location to APPDIR

if ($radioButton -eq "RadioButton_1"){
Copy-Item -Path $sampleOne -Destination $appDir
}

elseif ($radioButton -eq "RadioButton_2"){
Copy-Item -Path $sampleTwo -Destination $appDir
}
To implement this in Advanced Installer, please go to "Custom Actions" page. Here, please add a "PowerShell inline script" custom action, with sequence.

In the end, the script should look like this:
FinalScript.png
FinalScript.png (105.53 KiB) Viewed 11533 times

Some information about the "Copy-Item" PowerShell cmdlet can be found here:

https://docs.microsoft.com/en-us/powers ... wershell-7


This way, based on the Radio Button selection, one of your files will be installed.

Also, temporary files are deleted at the end of the installation ---> none of the files will be found on the target machine (in the temporary location) after the installation - only the copy filed will be found.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Features with Radio Buttons

Thank you for that very detailed explanation. I believe I understand this well now. If the file needed placed into a sub folder would it be something like..

Code: Select all

[APPDATA\Folder2\Folder3]
Last edited by mccorkled on Sat Feb 15, 2020 2:51 am, edited 2 times in total.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Features with Radio Buttons

Hello,

You are always welcome.

I am not quite sure I understand your question here. Could you please give me some more details?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Features with Radio Buttons

Catalin wrote: ↑Fri Feb 14, 2020 10:27 am I am not quite sure I understand your question here. Could you please give me some more details?
The PowerShell script is placing the file chosen into the root [APPDATA] folder. I need it to go into a sub folder within [APPDATA] Is the below the correct way?

Image

Also, when I run my installer it fails with the error...

Code: Select all

Dumping PowerShell invoke log ...
--> Found PowerShell path: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
--> PowerShell Script Execution Result Code: 574
dows 10\AppData\Local\Temp\pss7080.ps1 : Caught Exception: Missing 
an argument for parameter 'radioButton'. Specify a parameter of type 
'System.Object' and try again.
    + CategoryInfo          : NotSpecified: (:) , WriteErrorExcep 
   tion
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio 
   n,pss7080.ps1
I've tried several methods and am a bit stumped.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Features with Radio Buttons

Hello,

In order for me to further investigate this, please forward me a copy of your .AIP file, either here or by e-mail at support at advancedinstaller dot com.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Features with Radio Buttons

Ok, I sent it over. Thank you.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Features with Radio Buttons

Hello,

Thank you for the provided .AIP file.

After further investigating it, I have noticed that your radio button group has the following property:

Code: Select all

RADIO
not

Code: Select all

RADIOBUTTONGROUP_1_PROP
(you probably have renamed it)

With that being said, could you please change it in your PowerShell script?

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Features with Radio Buttons

Thank you! I am not sure how I missed that. I'm glad to know my modified script works. :)
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Features with Radio Buttons

You are always welcome!

I am glad everything is working as expected now.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Features with Radio Buttons

Hello guys,

This is a followup post in case more users are facing the same scenario, as we managed to find a much easier and elegant solution.

Basically, if you have two files with the exact same name and want to install only one based on a condition, you can proceed as it follows:

- in "Files and Folders" page, create two distinct folders under "Application Folder"

- in each folder, add your file
sample.png
sample.png (19.01 KiB) Viewed 8096 times

- right click on the first folder --> "Properties" --> select "Install folder content into the parent folder" option

- repeat the steps for the second folder as well

- now select your file and right click on it --> "Go to component". Here, you can condition the installation of the component

- repeat the above step for the second file as well

Hope this helps!

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

Return to “Building Installers”