Yes, it is possible to make force the APPDIR property to be a persistent property.
Here is how it can be achieved:
1. If you go to the "Registry" page, you can notice that the [APPDIR] property is saved into the registries at the following path:
HKLM:\SOFTWARE\<Manufacturer>\<ProductName> --> the "Path" value.
where "Manufacturer" is the "Publisher" field from "Product Details" page and "ProductName" is the "Name" field from the same page.
You can run a test installation to check this first hand.
Taking in consideration that this value is saved into the registries on every installation, we can use that in our advantage to use the value previously used for our current installation. To do so, you can proceed as it follows:
2. go to "Search" page and:
2.a) create a new search by right clicking on "Target Computer" --> "New Search"
2.b) now click on the earlier created search --> "Add search location" --> "Registry"
If a basic project (where Manufacturer=Your Company and ProductName=Your Application), the search can look like this:
After creating and testing the search, we can simply use a "SetProperty" custom action to set our current APPDIR to the value found in the registries (the APPDIR used in a previous installation). To do so, you can proceed like this:
3. go to "Custom Actions" page and:
3.a) add a "SetProperty" custom action with sequence (by pressing the "Add custom action with sequence" button which is placed to the right side of the custom action's name)
3.b) the custom action should look like this:
where [RESULT_PROPERTY] is the property that stores our search value. One important thing to do here is to uncheck the "First time install" option from under the "Dialogs Stage Condition" (we do not want this to execute on the first time install since we do not have anything to search in the registry in the first place).
Additionally, this custom action should be shared between the two execution stages (Wizard Dialogs Stage and Install Execution Stage). To do so, simply SHIFT + drag and drop it.
After doing so, please make sure that the second custom action also has the "First time install" option unchecked.
The sharing is done mainly due to the fact that, during a silent installation, the Wizard Dialogs Stage is skipped, and the property will not be set.
Hope this helps.