View Full Version : Update Installdir automatically - a new user

12-10-2004, 05:28 AM

Sorry if this is blindingly obvious to some, but I can't figure out how to do this:
I need to search the system for an executable
If the executable is not there I need to abort the installation
If it is there I need to set INSTALLDIR to the directory of the folder the exe's in

Can someone help quickly?

Or do I need scripts?



12-10-2004, 04:01 PM
Assuming you're using an MSI project, you can use the System Search functionality to look for your application.

In the System Search view (under "Behavior and Logic") right-click to launch the System Search Wizard, and select the type "Folder path, by searching for a file"; this will populate the value of a property you define, such as DIR_CONTAINING_MY_APP. At run time, this property will contain the directory containing your file, if it's located.

The wizard also lets you specify whether to use the property in a launch condition, which you want: if DIR_CONTAINING_MY_APP is undefined, you can specify a message to display, after which the installation exits.

If the search succeeds, you can use a set-a-directory custom action (after CostFinalize, in both the User Interface and Execute sequences) to set INSTALLDIR to [DIR_CONTAINING_MY_APP].

12-20-2004, 11:56 AM

Thanks for the help. Nearly there but not quite.

Yes I'm using an MSI project.

I followed the instructions you set.
The conditional installation works fine (i.e. if there's no file, the installation fails), but it seems to be writing the wrong thing to the INSTALLDIR property.

I get an error message stating 'Cannot create the directory [filename]. A file with this name already exists....' where [filename] is (the full path of) the file I searched for.

Is should be searching for a file and setting DIR_CONTAINING_MY_APP to the folder containing that file. Is this a bug?

I've looked in the tables and the only changes seem to be:
APPSEARCH has the Property name and the Signature name in correctly
DRLOCATOR has the Signature name, the path and parent columns are empty and the Depth is 6 as specified in the wizard
SIGNATURE has the Signature name, with the executable name in the FileName column
LAUNCHCONDITION has DIR_CONTAINING_MY_APP<>"" and the message to display
CUSTOM_ACTION has Action as SetInstallDir, Type as 35, Source as INSTALLDIR, Target as [DIR_CONTAINING_MY_APP] and ISComments empty

I can't see anywhere where it sets the search to be a search for a folder or a search for a file. Where should this be set (given that I selected the correct thing when addiung the System Search)?

Thanks for your help

12-21-2004, 10:06 AM
OK, found it in the help.

For info:
Need a second line in the DrLocator table to link the App file name to the App path, i.e.:

Signature table:
Signature | File name
AppFile | MyApp.exe

DrLocator table:
Signature | Parent
AppFile |
AppFolder | AppFile

AppSearch table:
Property | Signature

Matt Fry

09-08-2005, 03:09 PM
This is exactly what I have been looking for :D Thanks to the both of you.