stretch327
Posts: 9
Joined: Mon May 19, 2008 7:13 pm

Getting Parent of Searched File

If I know my user is going to have a file on their computer named test.exe and I want to install another file right next to it (or replace it), I know I need to create a search for that file, but how do I specify the file's parent for the installer?

GregO
stretch327
Posts: 9
Joined: Mon May 19, 2008 7:13 pm

Re: Getting Parent of Searched File

Ok, so in the help files under How To's, there's a help file that says:

How do I install some files in a folder of a previously installed application?

Answer
...
...
search for a file that you know to be present in the folder you are targeting.

- Once you have a property holding the path to the folder, must create a property-based folder.
- Go to the "Files and Folders" page.
- Use the "New Folder" toolbar button to create a new property-based folder. In the new window select the name of the search you have previously created.

This doesn't seem to work when I search for a file though – The installer tries to create a folder with the same name as the file it just found and put the files in there. I want it to put the files into the found item's parent directory (which is what the how to describes)

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

Re: Getting Parent of Searched File

Hi,

You can detect the file by using a search. After you have the path of the file, you can obtain the path of it's folder by using a custom action.

Here is a sample VBScript that does this for a search named "MY_SEARCH":

Code: Select all

Dim path
path=Session.property("MY_SEARCH")
smallPath=Left(path,InStrRev(path,"\")-1)
smallPath=Left(path,InStrRev(smallpath,"\"))
Session.property("MY_SEARCH")=smallPath
This custom action can be scheduled under the "InstallExecuteSequence" -> "AppSearch" standard action. You can see this standard action by using the "Show Standard Action" button on the toolbar in the "Custom Actions" page. Also, the "Function Name" field of the above custom action must be empty in order to run the script.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”