pfletch101
Posts: 24
Joined: Sat Aug 18, 2012 9:19 pm

Searching for folder containing specified file

Is it possible to use a Search to set an Installer Property to the folder path for a specific file, where the exact file name is known but the exact folder name isn't? Doing a file search returns a Property containing the full path to the file, including the file name. I would like to have the folder path without the file name, so that the installer can copy one or more files from that folder to folders created by the installation.
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Searching for folder containing specified file

Hello,

In order to achieve what you want you should take a look on our Find the folder which contains a file article. Also, when use a "File to Search" operation to search for your file, and you don't know exactly the folder location in which to search the file, then you can use a parent folder which contain your file and you can set a search depth accordingly.

Let us know if this helps, otherwise give us more details about your scenario.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
pfletch101
Posts: 24
Joined: Sat Aug 18, 2012 9:19 pm

Re: Searching for folder containing specified file

Thanks!

I am making some progress, but we are not quite there yet! I think you need a bit more detail in your Help about VBS Custom actions (and, indeed, about scripted Custom Actions in general). Also, the VBS scripts that you show on the page you pointed me to are not quite correct, since the working code is contained in Functions, without top-level code to call them.

In any event I have the (somewhat modified) VBS script installed and working, and have confirmed (with MsgBoxes) that it correctly saves the folder name in a Property (OLD_DATA_FOLDER), which I then use as the SOURCE property of a newly created folder on the Files, Folders, and Shortcuts page. After the Custom Action first runs (identical Actions are set to run after both Searches phases, since this seemed logical) the installer chugs away for some 20+ second (showing the "Computing Space Requirements" dialog) before reporting an error with the message: "Could not access network location OLD_DATA_FOLDER". The installation then aborts. I have attached the .aip. Any thoughts?
Attachments
EWMembership.aip
(30.88 KiB) Downloaded 651 times
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Searching for folder containing specified file

Hello,
I am making some progress, but we are not quite there yet! I think you need a bit more detail in your Help about VBS Custom actions (and, indeed, about scripted Custom Actions in general). Also, the VBS scripts that you show on the page you pointed me to are not quite correct, since the working code is contained in Functions, without top-level code to call them.
This happens because you have used an "Execute inline script code" custom action. You should use a "Launch attached file" or a "Launch installed file" custom action in order to call a function from a VBScript file. Then you can type the function name in the "Function" field from the "Custom Action Properties" right pane.

Also, here's attached a sample, created with version 9.4 of Advanced Installer, which implements your scenario.
sample.zip
(3.29 KiB) Downloaded 629 times
All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
pfletch101
Posts: 24
Joined: Sat Aug 18, 2012 9:19 pm

Re: Searching for folder containing specified file

Thanks! Correctly written :) inline VBS code does, in fact, work, though (now I understand better how the system operates!) using an attached file does seem a bit tidier, particularly if/when you need to edit the code. It is easy to lose or misplace a ":" when typing in multiline functions on one line. What I think was the real key to my problem was revealed by your example - the Data Folder Property Name needs to be declared as an install parameter (as well as "filled in" in the code), then it is automatically handled correctly when you manipulate its contents via the Files and Folders page. I imagine that you could get everything to work without initially declaring the Property Name, but there are more opportunities to do things wrong that way, and I had.

Two more related questions:
1) In your example, you are using a single custom action in two places in the sequence. How do you do that? I find that anything I do in an attempt to produce that effect (copy and paste, write a new custom action identical to the existing one) results in the creation of a second, functionally identical, custom action with a _1 appended to the name.

2) In my scenario, there exists the possibility that there is more than one instance of a specific file at the same level in the AppData tree (but in different branches). Is there any way for a file search to return multiple paths, rather than the path to the first instance encountered in a (on the basis of my experiments) depth-first search?
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Searching for folder containing specified file

Hello,
1) In your example, you are using a single custom action in two places in the sequence. How do you do that?
If you want to share a custom action between two standard actions, provided one it is located in the "Wizards Dialogs Stage" and the other in the "Install Execution Stage". Simply drag a custom action from one stage to the other, while pressing the Shift key. This is useful to ensure the custom action gets executed during a silent installation.

When your installation package is running with Full UI, searches from "Search" page are performed during "Wizard Dialogs Stage" -> "Searches" -> "AppSearch" standard action. If your installation package is running in silent mode, then searches from "Search" page are performed during "Install Execution Stage" -> "Searches" -> "AppSearch" standard action.
2) In my scenario, there exists the possibility that there is more than one instance of a specific file at the same level in the AppData tree (but in different branches). Is there any way for a file search to return multiple paths, rather than the path to the first instance encountered in a (on the basis of my experiments) depth-first search?
I'm afraid you cannot achieve this.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
pfletch101
Posts: 24
Joined: Sat Aug 18, 2012 9:19 pm

Re: Searching for folder containing specified file

Daniel.Radu wrote:Hello,
2) In my scenario, there exists the possibility that there is more than one instance of a specific file at the same level in the AppData tree (but in different branches). Is there any way for a file search to return multiple paths, rather than the path to the first instance encountered in a (on the basis of my experiments) depth-first search?
I'm afraid you cannot achieve this.
Daniel
I suspected that would be the answer, so I have written a vbs function to perform the full search and return the most recently modified file instance (which was what I needed). It is a bit slow, but it works!

Return to “Building Installers”