Detecting directory presence during installation

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>
+5
source share
3

, . CostFinalize (, "C: \" ), Windows.

, , "C: \" , . :

  • 51 ( ), (, [ProgramFilesFolder ] MyCompany\MyProduct ")
  • 51, .

, IS_INSTALLED, IS_INSTALLED_PATH. IS_INSTALLED_PATH , AppSearch IS_INSTALLED, -.

:

IS_INSTALLED

NOT IS_INSTALLED
+4

Understaing AppSearch RegLocator DrLocator . , , AppSearch . , . , .

:

<Condition>IS_INSTALLED/>   <!-- it not important what the value is, just that it exists -->
<Condition>Not IS_INSTALLED/>

Btw, INSTALLDIR. (InstallShield), .

0

: , InstallDir , SystemDir RegisteryDir

<Property Id="RegisteryDir" Secure="yes">
<RegistrySearch Id='InstallDir' Type='directory'
Root='HKLM' Key='Software\Company\Product\Install' Name='InstallPath'/>
</Property>
<Property Id='SystemDir' Secure='yes'>
<DirectorySearch Id='IsInstalled' Path='[RegisteryDir]' />
</Property>
<CustomAction Id="SET_INSTALL_DIR" Property="INSTALLDIR" Value="[SystemDir] />

<InstallExecuteSequence>
<Custom Action='SET_INSTALLDIR' After='AppSearch'>
SystemDir AND SystemDir=RegisteryDir
</Custom>
</InstallExecuteSequence> 
0
source

All Articles