In WiX DirectorySearch can be used to determine if a specific directory exists on the target computer. But I don't understand if there's a consistent way to determine that a directory does not exist.
For example:
<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 IS_INSTALLED property is set to the path returned by DirectorySearch.
When the directory does not exist, IS_INSTALLED appears to be set to "C:\".
Is a condition like:
<Condition>NOT (IS_INSTALLED = "C:\")</Condition> a reliable way to detect that the directory was found? Is there a better way?
Answer: Here is WiX code based on mrnxs answer that 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>