Search for a directory containing a file - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

crairdin
Posts: 15
Joined: Wed Mar 07, 2007 7:26 pm

Search for a directory containing a file

I'm using AI 4.8.

I am installing a data file for a program that is already installed on the user's machine. Technically I don't know where the user has installed the program, but it ought to be in C:\Program Files\asdf. The program name is qwerty.exe.

I thought I'd use a search to locate qwerty.exe then install to the directory containing that file. I can create the search, but I can't figure out how to make my Application Directory be the directory that contains the file I was searching for.

Then I thought I'd use a search to locate the directory asdf, then install there. That works as long as the directory exists. If it doesn't, then my file is installed to asdf but that doesn't do much good because the qwerty.exe program is going to look for it somewhere else. I tried creating a prerequisite that would test to see if the target of the search existed, but I couldn't figure out how to do that.

Also, since I know the program is probably in C:\Program Files\asdf, it seems dumb to search for asdf then always install to C:\Program Files\asdf even if it doesn't exist. So for now I've given up on searching and I just install to [ProgramFilesFolder]asdf. This works as long as the user didn't change the default location of the original program when they installed it.

I should point out that the installer for qwerty.exe isn't under my control (actually it is but there are thousands of existing copies out there that I can't "recall") so I don't have the option of writing a registry value or something like that during install of qwerty.exe.

So what I really want to do is search [ProgramFilesFolder] and its subfolders for qwerty.exe. When I find it, I want to install my data file to the folder that contains that file. How do I do that with AI?

Thanks for your help.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

This can be achieve very easy using Advanced Installer. Here is how you can do it:

Create a new folder search in the "Search" page "New Search->Add Location->Folder". The result is stored by default in the "RESULT_PROPERTY".

Switch in the custom action page and add a "New Custom Action->Property Set with Formatted" under "InstallUISequence->AppSearch". Use following options for the custom action:

Property Name: APPDIR (application folder)
Formatted Text: [RESULT_PROPERTY] (the result of the search)
Execution Condition: RESULT_PROPERTY (the custom action will be executed only if the search succeed)

Now drag this custom action while shift key is pressed and drop it under "InstallExecuteSequence->AppSearch". Use the same "Execution Condition".

Hope this helps. Let me know if you encounter any problems.

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
crairdin
Posts: 15
Joined: Wed Mar 07, 2007 7:26 pm

Your solution seems to be looking for a folder and installing to that folder if it is found. What I want to do is search for a file, then install to the folder containing the file if it is found.

If it is not found I'd like to display a custom error message of some kind, but would accept installation to some default folder.

If I do a search for the qwerty.exe FILE then follow your instructions, the installer will try to install my add-on to the FOLDER called "C:\Program Files\asdf\qwerty.exe\".

Craig
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi Craig,

Windows Installer does not offer directly support for this. So ifyou want to use a file search then you need to create a custom action to remove the file name from the resulted path. You need to schedule this custom action before the "Property Set with Formatted" one (that sets the APPDIR to the search result) in both sequence (UI and Execute).

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”