In WiX, DirectorySearchyou can use it to determine if a specific directory exists on the target computer. But I do not understand if there is a consistent way to determine that the directory does not exist .
For instance:
<Property Id="INSTALLDIR" Secure="yes">
<RegistrySearch Id='InstallDir' Type='directory'
Root='HKLM' Key='Software\Company\Product\Install' Name='InstallPath'/>
</Property>
<Property Id='IS_INSTALLED' Secure='yes'>
<DirectorySearch Id='IsInstalled' Path='[INSTALLDIR]' />
</Property>
When both the registry key and the directory exist, the property is IS_INSTALLEDset to the path returned DirectorySearch.
When the directory does not exist, IS_INSTALLEDappears as "C: \".
This condition is like:
<Condition>NOT (IS_INSTALLED = "C:\")</Condition>
a reliable way to find that a directory is found? Is there a better way?
Answer: Here is the WiX code based on the mrnxs answer I accepted
<Property Id="PRODUCT_IS_INSTALLED" Secure="yes">
<RegistrySearch Id='RegistrySearch1' Type='directory'
Root='HKLM' Key='Software\Company\Product\Version\Install' Name='Path'>
<DirectorySearch Id='DirectorySearch1' Path='[PRODUCT_IS_INSTALLED]'/>
</RegistrySearch>
</Property>
<CustomAction Id='SET_INSTALLDIR'
Property='INSTALLDIR'
Value='[PRODUCT_IS_INSTALLED]'/>
<InstallExecuteSequence>
<Custom Action='SET_INSTALLDIR' After='AppSearch'></Custom>
</InstallExecuteSequence>
source
share