Hello Jacob,
sorry but I'm not quite expert in advanced installer yet, but what custom action should I create exactly?
What my colleague Daniel meant is that you can create, for instance, a script (e.g. PowerShell, VBScript, C#) and add it in your project as a custom action. This script should get the value of your property (in this case, MY_DIR property) and check if a file exists inside that directory. This is what he meant by:
and search for target program file inside this folder location
For your reference, I have created a small PowerShell script which does what you need:
Code: Select all
# Block for declaring the script parameters.
Param()
# Your code goes here.
# this is added so we can use the MessageBox class. It was added for testing purposes only and can be removed
Add-Type -AssemblyName PresentationFramework
# use the AI_GetMsiProperty cmdlet to get the value of the MY_DIR property and then we store it in the $path variable
$path = AI_GetMsiProperty MY_DIR
# we display the path. Again, this is for testing purposes only and can be removed
[System.Windows.MessageBox]::Show($path)
# the path we have earlier stored is a path to a directory. In this case, we will need the full path to a file, therefore we have to append the file name
# at the end of the path. To do so, we can use the Join-Path cmdlet
$fullPath = Join-Path -Path $path -ChildPath your_file.extension
# we display the full path
[System.Windows.MessageBox]::Show($fullPath)
# we test the full path using the Test-Path cmdlet. This returns True if the path exists and False otherwise.
$test_response = Test-Path -Path $fullPath
# we display the test response. This can be removed after testing is done
[System.Windows.MessageBox]::Show($test_response)
# I think that here, you may need only the else statement. Basically you only want to check if the file DOES NOT exist
if ($test_response -eq $true){
# this means the file is not missing
[System.Windows.MessageBox]::Show("The file is not missing")
}
else {
# this means the file is missing, therefore we should set the property, as explained by my colleague
AI_SetMsiProperty MISSING_PROP true
}
This custom action can be added in Advanced Installer as a
"Run Inline PowerShell script" custom action.
Now, after executing this custom action, if the file does not exist ==> the property will be set (the MISSING_PROP) and you will be able to use that as a condition, as explained by my colleague Daniel.
Hope this helps and things are clearer for you now.
Best regards,
Catalin