buzz71
Posts: 25
Joined: Tue Nov 02, 2010 11:03 am

Conditionally Creating Folders

Hi

Is it possible to conditionally create folders in Advanced Installer?
i.e. I want to create a folder if the O/S is W2008 and UAC is running. I wish to create a folder in "C:\Users\Public\MyInstall" placing a number of the configuration files in the folder as it is a writeable area.

Additionally, is there an AI pre-defined selectable folder for this area (C:\Users\Public)?, i.e. "Public Folders (PublicDocumentsFolder)"?

Thanks in advance.

Buzz
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Conditionally Creating Folders

Hi Buzz,
Is it possible to conditionally create folders in Advanced Installer?
Yes, you can use a feature to control the folder installation:
- make sure that the folder is not added in your project
- in Organization page create a new feature
- in "Files and Folders" page select that feature in Feature toolbar combo box
- add your folder

This way the folder content is added in your custom feature. This feature can be conditioned through the "Install based on condition" option in Feature Properties pane.
I want to create a folder if the O/S is W2008 and UAC is running.
You can detect the Windows version by using VersionNT property. To determine if UAC is enabled you can use a registry search for this entry:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
If it's set to "1" the UAC is enabled.
I wish to create a folder in "C:\Users\Public\MyInstall" placing a number of the configuration files in the folder as it is a writeable area.
Unfortunately this is not a predefined folder in Windows Installer. Can you please give me more details about why you want to use it? Most applications use a folder in ProgramData ("Common Application Data" in Advanced Installer).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
buzz71
Posts: 25
Joined: Tue Nov 02, 2010 11:03 am

Re: Conditionally Creating Folders

Hi Cosmin

Thank you for the info. With this I have set up a registry search and the new Feature in the tree with a "Install based on condition". What should I select for the directory in the Feature dialog? I can only select "Target Computer" -> "Application Directory" which is not what I want?
in "Files and Folders" page select that feature in Feature toolbar combo box
I then select the new Feature in "Files and Folders" dropdown but the view does not change. Should it? I can still see the items I added in "MainFeature".
Unfortunately this is not a predefined folder in Windows Installer. Can you please give me more details about why you want to use it? Most applications use a folder in ProgramData ("Common Application Data" in Advanced Installer).
It was a customer request to use the "C:\Users\Public\MyInstall" folder. Is it posible to specify this somehow?

For my information, the "Common Application Data" folder usually gets written to which folder?

Thanks

Buzz
buzz71
Posts: 25
Joined: Tue Nov 02, 2010 11:03 am

Re: Conditionally Creating Folders

Hi Cosmin

I have got a bit further now - I get the choice of folders in the Feature Dialog of wherever there are folders entered into the Files & Folders structure. So here is no need for an answer to question one.

The remaining 3 questions stand however.

Thanks in advance.

Buzz
buzz71
Posts: 25
Joined: Tue Nov 02, 2010 11:03 am

Re: Conditionally Creating Folders

Hi Cosmin

I have been considering this problem further.

If it is not possible to get to "c:\Users\Public\MyInstall" from selecting from the pre-defined list of folders would the following be possible?

1. Display a dialog if installation is on the W2008 O/S & UAC is enabled (using the conditional info you gave me in 1st reply).
2. The dialog collects an 'alternate' folder to the main install directory from the user (where they could select "c:\Users\Public\MyInstall") for the writeable data.
3. Create and copy files to this folder ONLY if the above condition is met.

Please could you comment on my questions from previous reply also?
I then select the new Feature in "Files and Folders" dropdown but the view does not change. Should it? I can still see the items I added in "MainFeature".

It was a customer request to use the "C:\Users\Public\MyInstall" folder. Is it posible to specify this somehow?

For my information, the "Common Application Data" folder usually gets written to which folder?
Thanks

David
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Conditionally Creating Folders

Hi David,
What should I select for the directory in the Feature dialog?
You can leave the default. It doesn't affect the folder.
I then select the new Feature in "Files and Folders" dropdown but the view does not change. Should it? I can still see the items I added in "MainFeature".
No, the view doesn't change. The "Feature" combo sets the current feature, in which all resources are added automatically from now on. You first need to select your feature so it's set as current and only then add your folder. If you already added your folder, you need to remove it, select the feature and then add it again.
It was a customer request to use the "C:\Users\Public\MyInstall" folder. Is it posible to specify this somehow?
Yes, you can try this approach:
- create a custom public property in "Install Parameters" page
- use it for a property-based folder in Files and Folders page
- add your files in it
- write a Win32 DLL or VBScript custom action which generates the "C:\Users\Public\MyInstall" path and sets it in your custom property
- add it as a custom action before "InstallUISequence" -> "CostFinalize" in Custom Actions page

Instead of a DLL or VBScript you can also use a Property set with formatted custom action which sets your property to:

Code: Select all

[WindowsVolume]Users\Public\MyInstall
But this may not be the exact path on some machines due to folder redirection and Windows localization.
For my information, the "Common Application Data" folder usually gets written to which folder?
"C:\ProgramData".
1. Display a dialog if installation is on the W2008 O/S & UAC is enabled (using the conditional info you gave me in 1st reply).
2. The dialog collects an 'alternate' folder to the main install directory from the user (where they could select "c:\Users\Public\MyInstall") for the writeable data.
3. Create and copy files to this folder ONLY if the above condition is met.
Our user guide contains the Browse for folder how-to which explains this.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Ladine
Posts: 5
Joined: Thu Aug 24, 2017 11:10 am

Re: Conditionally Creating Folders

Cosmin wrote:Hi Buzz,
Is it possible to conditionally create folders in Advanced Installer?
Yes, you can use a feature to control the folder installation:
- make sure that the folder is not added in your project
- in Organization page create a new feature
- in "Files and Folders" page select that feature in Feature toolbar combo box
- add your folder

This way the folder content is added in your custom feature. This feature can be conditioned through the "Install based on condition" option in Feature Properties pane.
I want to create a folder if the O/S is W2008 and UAC is running.
You can detect the Windows version by using VersionNT property. To determine if UAC is enabled you can use a registry search for this entry:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
If it's set to "1" the UAC is enabled.
I wish to create a folder in "C:\Users\Public\MyInstall" placing a number of the configuration files in the folder as it is a writeable area.
Unfortunately this is not a predefined folder in Windows Installer. Can you please give me more details about why you want to use it? Most applications use a folder in ProgramData ("Common Application Data" in Advanced Installer).

Regards,
Cosmin
Hello,

I have a sinilar problem, where a folder should only be created if a checkbox is selected. I tried to follow the steps but I can't seam to get it to work
I have a property called "INSTALLJRE" which is set to "YES" as default
I have a feature containing the jre folder which should only be installed if INSTALLJRE=YES (or should it be INSTALLJRE="YES" ?)
I have adialog with a checkbox, checkbox has Property Name set to INSTALLJRE , value set to [INSTALLJRE] and the correct default value form the INSTALLJRE-property
The Next-button has an event [PropertyName] with Argument [INSTALLJRE] in published Event
So basically if the user unchecks the box INSTALLJRE should be set to NO (or whatever not YES)

But no matter if I uncheck the box in my tests the jre-folder is installed. The log file states that the INSTALLJRE-property was set to YES and is deleted. INSTALLJRE is passed with an empty value in the comand line in the log file.

So HOW do I get it to work ? reliably ?

Thanks in advance
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Conditionally Creating Folders

Hello,
I have a feature containing the jre folder which should only be installed if INSTALLJRE=YES (or should it be INSTALLJRE="YES" ?)
It be should INSTALLJRE="YES", or simply INSTALLJRE

The most straight-forward method for conditioning a feature install by a checkbox is the following:
- create a checkbox. Let's asume the property associated to this checkbox is "INSTALLJRE"
- go to "Organisation" page and select the feature you want to condition. Select "Not Installed" from "Installation Behavior" section. In the "Installed if" field enter the following condition:

Code: Select all

INSTALLJRE
If this isn't helpful, please send us the .AIP (project) and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Ladine
Posts: 5
Joined: Thu Aug 24, 2017 11:10 am

Re: Conditionally Creating Folders

Thanks, I tried this unfortunately didn't work. Unfortunatly I don't know if I can sent you the aip-file (probably not, may be a smaller one) . We are using Advance Installer 8.9 if that helps.
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Conditionally Creating Folders

Hello,

In order to enable us to further invetigate your issue, please upload your project on a server (e.g. Dropbox) and send the download link to support at advancedinstaller dot com. If you could not send us the whole project, a sample project reproducing this issue would be very helpful as well.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”