Wix: How to do DirectorySearch in a custom installation location

I would like to know if the directory exists in the user installation location selected by the user in the GUI. I tried the following:

<Property Id="DIRECTORY_PATH"> <DirectorySearch Id="DirectorySearch" Path="[INSTALLDIR]\MyDirectory" /> </Property> 

But this does not work, because DirectorySearch occurs during AppSearch. Although INSTALLDIR is installed later during InstallDirDlg. Because INSTALLDIR is not set for AppSearch, DIRECTORY_PATH is not set correctly to "\ MyDirectory".

I tried to change when AppSearch happens with InstallUISequence and InstallExecuteSequence installation, but this will only let AppSearch exit before CostInitialize, no later.

So, how do I look for a directory in the user-selected INSTALLDIR location?

+6
source share
2 answers

If you only need to wait for the user to check this directory, then DirectorySearch will not do the work for you. You will need to create a custom action "set property" immediately after the user selects INSTALLDIR, for example, in the next InstallDirDlg click.

UPDATE So, I basically mean the following:

  • when the user gets to InstallDirDlg of your installation, he selects the directory that is placed in the INSTALLDIR property
  • the InstallDirDlg dialog should then activate the user action in the next button
  • this custom action should get the value of the INSTALLDIR property and execute a simple file system, check if INSTALLDIR contains MyDirectory
  • if so, the DIRECTORY_PATH property is set to the desired value, for example. session["DIRECTORY_PATH"] = session[INSTALLDIR] + "\MyDirectory";
  • otherwise DIRECTORY_PATH is not set (and you can use this fact in any state by checking NOT DIRECTORY_PATH )

Hope this makes sense.

+3
source

Hope this helps you.

If you saved the INSTALLDIR of the previous installation in the registry, you can get it and search. In the UI installation sequence, the Installtion location will point to the previous location.

 <!-- Set previous install location, if available --> <Property Id="INSTALLDIR" Secure="yes"> <RegistrySearch Id="InstallRootRegistry" Type="raw" Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Name="INSTALLDIR" /> </Property> <!-- The property WIXUI_INSTALLDIR must be set for the UI to know which directory to use as default --> <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" Secure="yes"/> 
0
source

Source: https://habr.com/ru/post/896927/


All Articles