If you want to restore a previously existing registry key, you would have
had to have saved it someplace, or at least saved the fact that it
previously existed with enough information to recreate it. That means that
in your RegistrySearches you would need to be able to distinguish the
difference between a non-existent key (that you are defaulting, perhaps?)
and a previously existing key.

Or, can you change the situation a bit? Is it bad to leave the registry key
behind when you uninstall? Sometimes old droppings really aren't as bad as
the destruction that can be caused by trying to do a comprehensive job
cleaning up after yourself.

-----Original Message-----
From: Jan Wester [mailto:happyhon...@gmail.com] 
Sent: Saturday, November 21, 2009 11:37 AM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] Conditional registry entries and handling them properly
on uninstall

Hello WiX community,

After the advice given to me yesterday, I've been focusing on the
subject I've had least replies on. Basically, I am trying to only
write a registry entry if it does not exist and create some keys to go
with it, or if it does exist, I want to modify things, and at
uninstall time, restore things to how they were. Since my attempts so
far combined with examples will probably be more informative, here
they come:

<Property Id="PROGID_XYZ" Value="Test.ProgID">
      <RegistrySearch Id='ExtXyzRegistry' Type='raw'
        Root='HKLM' Key='Software\CLASSES\.xyz' />
</Property>

That ought to fill PROGID_XYZ with an already existing ProgID, or if
the filetype is unknown, substitute my own default handler.

<Component Id="ComponentXYZ" Guid="<snip>">
  <snip>
  <RegistryKey Root="HKLM" Key="Software\Classes\[PROGID_XYZ]"
                Action="createAndRemoveOnUninstall">
    <RegistryValue Type="string" Name="SomeWeirdValue" Value="Stuff" />
  </RegistryKey>
</Component>

This created the value in the proper place, but upon uninstallation,
it removed the entire key, which makes sense since I asked it to. But
in this case, the RegistrySearch was successful, and thus the
appropriate ProgID already existed, and I essentially wiped out the
file associations. Oops. How can I avoid this? If I were to make it
action="create", I would never remove the handler afterwards if I
understand correctly.

To have it all in a little neat list, these are the requirements I am
trying to achieve:
* .XYZ exists - make changes in existing ProgID.
* .XYZ does not exist - make the .XYZ key, and make my default ProgID.
* Uninstallation: .XYZ already existed at installation - place back
any settings I overwrote in the 'foreign' ProgID, and remove any new
entries I made.
* Uninstallation: .XYZ never existed at installation - remove .XYZ and
my default ProgID.

I have studied conditions, features, components and the various
options available to me with a RegistrySearch, but I am pretty much
lost. As such I appreciate any advice or examples you folks can give
me to work off. :)

Regards,

Jan Wester

----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus
on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to