Catalin
Posts: 7794
Joined: Wed Jun 13, 2018 7:49 am

Install files into a folder retrieved by a search, only if the search was successful

Hello,

Today we'll be discussing about an interesting scenario I got from one of our customers.

Say you have a plugin file that you want installed for a 3rd party product, such as Adobe.

Now, you do not know which Adobe version your client has installed, so you want to cover all cases.

To do so, create a search for each of the Adobe that might be present on the machine. Such search can look like this:
Screenshot_131.png
Screenshot_131.png (5.82 KiB) Viewed 24670 times

As you can see, it retrieves the path from the registries where the plugin should be installed and stores the path into a property, e.g. ADOBE_22.

Now, for each version of Adobe, we create a property based folder in the "Files and Folders" page, like so:
Screenshot_132.png
Screenshot_132.png (2.07 KiB) Viewed 24670 times

Now, the problem the customer encountered was the fact that, if the search did not result into anything, the plugin would be copied into a folder like C:\ADOBE_22.

This is the normal behavior, as the default path for a property based folder is ROOTDRIVE:\PROP_NAME.

ROOTDRIVE property
If the Directory column of the Directory table indicates the root destination directory by a property name that is undefined, the installer uses the value of the ROOTDRIVE property to resolve the path to the destination directory.
So, if the search does not result into anything, a folder with the name of the property will be created on the rootdrive, in our case that being C:\.

The solution to this will be presented below, step-by-step:
  • copy each search you have in the Search page and name it something like ADOBE_22_EXISTS
Screenshot_133.png
Screenshot_133.png (15.51 KiB) Viewed 24670 times
Note: nothing changes here, besides the name of the search.

  • use the new properties as conditions for each component
Screenshot_134.png
Screenshot_134.png (57.9 KiB) Viewed 24670 times

Now, at install time, only the folders for which the registry search returned something should be created on the disk. The other folders created with the default path of ROOTDRIVE:\PROP_NAME should no longer be created.

Hope this helps! :)

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

Return to “Sample Projects”