Wednesday, March 23, 2011

writing registry in wix - problem illustrated with sample wxs file.

I am trying to write to registry using Wix.

it is failing showing the error "The error code is 2727"

to run this sample follow the below steps.

you need a text file in c:\testinstall.txt

it installs the file testinstall.txt in C:\Program Files\testinstall

candle sample.wxs light sample.wixobj

sample.msi will be created

when i add this entry in the script it is failing.

all i need is to have a script which will create a key and write some value into the registry.

sample.wxs code

2

  <Registry Id="TestKey" 
     Root="HKLM" 
     Key="SOFTWARE\testCorp" 
     Action="createKeyAndRemoveKeyOnUninstall"> 

 <Registry Id="TestValue" 
           Name="TestValue" 
           Action="write" 
           Value="123" 
           Type="string" /> 
 </Registry> 

  </Component>

   </Directory>
  </Directory>
</Directory>

<Feature Id="Feature" Level="1">
 <ComponentRef Id="component0" />
 <ComponentRef Id="ID0EAAA" />
</Feature>

From stackoverflow
  • Are you using WiX v2? Instead of creating the registry value with two Registry entries, just combine it all into one line.

    <Registry Id="TestKey" Root="HKLM" Key="SOFTWARE\testCorp" Name="TestValue" Value="123" Type="string" Action="write" />
    

    That's usually a lot easier. If you really want to nest them then I recommend leaving the Registry/@Action attribute off of the parent registry key so it doesn't actually end up in the MSI. Just organizes the child elements.

    Note the syntax is a bit different in WiX v3.

0 comments:

Post a Comment