jsullivan84
Posts: 2
Joined: Thu May 04, 2017 8:42 pm

Custom Action: Install files into specfic folder using a search

Hi,

I am trying to build an installer and place some custom files into a certain location. This location is for another program installed on a PC. However this location can vary depending on the version of software that is installed on that PC. How can I do a search, for a certain folder, but within that folder find the folder I want. (This may not make any sense) Currently I need to rebuild the installer and change this location for a different customer.

Folder Breakdown:

Common Application Data
Freedom Scientific
JAWS
17 (This is the folder name that changes, depending on the version of software installed I need to be able to find this, other wise the files will not be in the final location)
Settings
ENU(This is the folder where my files need to be placed.)

I hope this makes sense.

Thanks!

Jill
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action: Install files into specfic folder using a search

Hello Jill and welcome to our forum!

A possible method would be searching for a file contained by the folder you are searching for and, after the file is found, the path containing the file should be extracted with a script.

This can be done by using the following steps:

1. Go to "Search" page and and create a new file search named "SEARCH_PROPERTY". You need to search for a file contained by the ENU Folder, for example "a.txt". Right click on "SEARCH_PROPERTY" and select "Add Location - Folder". Enter [CommonAppDataFolder] as a path and "6" in "Depth" field.

This search will return "C:\ProgramData\Freedom Scientific\JAWS\17\Settings\ENU\a.txt".

2. Create a new "Set Installer Property" custom action with sequence and place it before "Searches" action group in "Wizard Dialogs Stage" and in "Install Execution Stage" too. Use this custom action to set PATH property to a valid path, for example [CommonAppDataFolder]. This step is necessary in case the file is not found by the search action.

3. Create a new "Execute Inline Script" custom action with sequence and place it after "Searches" action group in "Wizard Dialogs Stage" and in "Install Execution Stage" too. Use the following VBS code:

Code: Select all

'retrieve the file path from the search operation
filePath = Session.Property ("SEARCH_PROPERTY")

'if file is found on the target machine
If Len(filePath) > 0 Then

'retrieve folder path
folderPath = Left ( filePath, InStrRev (filePath, "\") - 1)

'set the installation path with this value
Session.Property ("PATH") = folderPath
End If
This code will extract the path from the "SEARCH_PROPERTY" result and place it to "PATH" property. In your case "PATH" will receive : "C:\ProgramData\Freedom Scientific\JAWS\17\Settings\ENU\"

4. Depending on your needs, set "PATH" property either as a property based folder - to deploy some of your files in it or go to "Install Parameters" page set "Application folder" to [PATH] to deploy all your files in it

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jsullivan84
Posts: 2
Joined: Thu May 04, 2017 8:42 pm

Re: Custom Action: Install files into specfic folder using a search

Thanks,

I guess I am not doing this correctly and I am getting stuck at the second step 3, which i assume is step 4.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action: Install files into specfic folder using a search

Hello Jill,

I've updated the duplicated step 3 in my previous post to be 4. :)

At step 4 you should proceed like this:
a. go to "Install Parameters" page and add define the "PATH" property like this
  • Name: PATH
    Value: Your value
b. go to "Files and Folders" page and use the [New Folder] -> [Property Based] ribbon button to create a property based folder using the PATH property
c. under the new created property based folder add the desired files to be installed under this location

Let us know if this helped otherwise please give us more details about your requirements.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jes
Posts: 34
Joined: Mon Oct 23, 2017 12:51 pm

Re: Custom Action: Install files into specfic folder using a search

Re: Custom Action: Install files into specfic folder using a search
Post by Daniel » Fri May 05, 2017 1:12 pm

Hello Jill and welcome to our forum!

A possible method would be searching for a file contained by the folder you are searching for and, after the file is found, the path containing the file should be extracted with a script.

This can be done by using the following steps:

1. Go to "Search" page and and create a new file search named "SEARCH_PROPERTY". You need to search for a file contained by the ENU Folder, for example "a.txt". Right click on "SEARCH_PROPERTY" and select "Add Location - Folder". Enter [CommonAppDataFolder] as a path and "6" in "Depth" field.

This search will return "C:\ProgramData\Freedom Scientific\JAWS\17\Settings\ENU\a.txt".

2. Create a new "Set Installer Property" custom action with sequence and place it before "Searches" action group in "Wizard Dialogs Stage" and in "Install Execution Stage" too. Use this custom action to set PATH property to a valid path, for example [CommonAppDataFolder]. This step is necessary in case the file is not found by the search action.

3. Create a new "Execute Inline Script" custom action with sequence and place it after "Searches" action group in "Wizard Dialogs Stage" and in "Install Execution Stage" too. Use the following VBS code:
CODE: SELECT ALL
'retrieve the file path from the search operation
filePath = Session.Property ("SEARCH_PROPERTY")

'if file is found on the target machine
If Len(filePath) > 0 Then

'retrieve folder path
folderPath = Left ( filePath, InStrRev (filePath, "\") - 1)

'set the installation path with this value
Session.Property ("PATH") = folderPath
End If


This code will extract the path from the "SEARCH_PROPERTY" result and place it to "PATH" property. In your case "PATH" will receive : "C:\ProgramData\Freedom Scientific\JAWS\17\Settings\ENU\"

4. Depending on your needs, set "PATH" property either as a property based folder - to deploy some of your files in it or go to "Install Parameters" page set "Application folder" to [PATH] to deploy all your files in it

Let us know if this helped.

All the best,
Daniel


Hi,
Can we set the path of result_property to path of TEMP folder ?

Thanks!!
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action: Install files into specfic folder using a search

Hello,

I'm not sure I fully understood your requirement. Do you need to search for a file in the temp folder? If not, can you please give us more details about your requirement?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”