Search code examples
wixwindows-installerregistry

WIX Toolset MSI. How to read folder name from registry?


This code gives me the value of the PowerShellVersion key.

 <Property Id="POWERSHELLVERSION">
      <RegistrySearch Id="POWERSHELLVERSION"
                      Type="raw"
                      Root="HKLM"
                      Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
                      Name="PowerShellVersion"/>
 </Property>

How can I get the name of the folder? For example, I need to find the name of the PowerShellEngine folder in folder 3 and assign it to Property "POWERSHELLVERSION".

 <Property Id="POWERSHELLVERSION">
      <RegistrySearch Id="POWERSHELLVERSION"
                      Type="raw"
                      Root="HKLM"
                      Key="SOFTWARE\Microsoft\PowerShell\3"
                      Name="PowerShellEngine"/>
 </Property>

Solution

  • This would assign the value C:\Windows\System32\WindowsPowerShell\v1.0 to POWERSHELLLOCATION.

     <Property Id="POWERSHELLLOCATION">
          <RegistrySearch Id="POWERSHELLVERSION"
                          Type="raw"
                          Root="HKLM"
                          Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
                          Name="ApplicationBase"/>
     </Property>