cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Occasional contributor

Registry component best practices: Property values in registry reset after patch

Jump to solution

I want to know if there are best practices for using a component specifically for registry entries in which a property is used to update a value.

Here's the situation I need help with:

  1. you have a component that creates a registry key: HKLM\SOFTWARE\My Company\TestDirectory
  2. the value of TestDirectory is a String Value from a property called [TESTDIRECTORY] with a default value of "C:\Foo"
  3. if you launch the install's .msi from the command line and pass \TESTDIRECTORY="C:\Junk" the value in the registry gets updated to this new value as expected. All is well.
  4. Now I create an update patch.
  5. I launch the patch manually without passing any values to it. 
  6. After the patch is complete, if I go to the registry I find that the value of the TestDirectory registry key has reverted to the default value: "C:\Foo." This is because the patch has reinstalled/refreshed all the files. This is not what I want.

The way I get around this is I create a new System Search for this registry key, and save the value into a different property, say, [TESTDIRECTORY_TEMP]. I then create a new Set Property custom action that populates [TESTDIRECTORY] with [TESTDIRECTORY_TEMP], and set the condition for this custom action to be "Installed." This works, but it seems there must be a better way.

I find this value resetting doesn't happen with canned properties such as COMPANYNAME, or USERNAME.

Is there a better way to handle these types of properties so that they don't get reset after a patch?

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Active participant

Re: Registry component best practices: Property values in registry reset after patch

Jump to solution

Scott,

You don't need the custom action and you don't need the TESTDIRECTORY_TEMP property.  Just do the following:

  1. In the Property Manager, have an entry for TESTDIRECTORY and give it the default value you want
  2. Create a System Search that looks for the value that you set in your registry component

That's all you need to do!

When the Windows Installer loads your msi into memory, it sets the value of TESTDIRECTORY to the default value you set in the Property Manager.  If you don't set the property TESTDIRECTORY on the MSIEXEC command line, it will not change that value.  If you do set its value (by specifying TESTDIRECTORY="C:\Junk", for example, that will change the value of TESTDIRECTORY.  Note there is no slash or backslash before the property name), that will change the value of TESTDIRECTORY  from the default value to whatever you have entered on the command line.  The System Search will not find the registry value since that registry value won't exist, so the value will not be changed,  In either case (whether you set the value on the command line or not), at the end of a successful installation, the value of TESTDIRECTORY will be present in the registry.

Later, when you deploy a patch, the System Search will find the value that value in the registry which will change the value of TESTDIRECTORY from the default value you set in the Property Manager to what exists in the registry. 

Hope this helps.

View solution in original post

3 Replies
Highlighted
Active participant

Re: Registry component best practices: Property values in registry reset after patch

Jump to solution

Scott,

You don't need the custom action and you don't need the TESTDIRECTORY_TEMP property.  Just do the following:

  1. In the Property Manager, have an entry for TESTDIRECTORY and give it the default value you want
  2. Create a System Search that looks for the value that you set in your registry component

That's all you need to do!

When the Windows Installer loads your msi into memory, it sets the value of TESTDIRECTORY to the default value you set in the Property Manager.  If you don't set the property TESTDIRECTORY on the MSIEXEC command line, it will not change that value.  If you do set its value (by specifying TESTDIRECTORY="C:\Junk", for example, that will change the value of TESTDIRECTORY.  Note there is no slash or backslash before the property name), that will change the value of TESTDIRECTORY  from the default value to whatever you have entered on the command line.  The System Search will not find the registry value since that registry value won't exist, so the value will not be changed,  In either case (whether you set the value on the command line or not), at the end of a successful installation, the value of TESTDIRECTORY will be present in the registry.

Later, when you deploy a patch, the System Search will find the value that value in the registry which will change the value of TESTDIRECTORY from the default value you set in the Property Manager to what exists in the registry. 

Hope this helps.

View solution in original post

Highlighted
Occasional contributor

Re: Registry component best practices: Property values in registry reset after patch

Jump to solution

Thank you for the reply. You're right, the custom action is not necessary. Simply performing a system search as you said does the trick. However, investigating a little further, with this technique (and my technique) I'm locked into whatever value is in the registry. So, for example, if I were to run my patch from the command line like so:  Update.exe /s /v"TESTDIRECTORY=SomeRandomValue /qb", the value in the registry does not get updated to "SomeRandomValue" and instead stays with the current value.

0 Kudos
Highlighted
Active participant

Re: Registry component best practices: Property values in registry reset after patch

Jump to solution

Scott-

I didn't see that need in your original problem statement, so I didn't address it.

To get that registry value updated, that registry-only component needs to get reinstalled.  The easiest thing I can think of to make that happen is to have one or more files associated with that component (and if more than one file, one of the files designated as the Key File of the component).  In the properties of that Key File, check the box "Always Overwrite".  If you really don't want to have one of your application files associated with the registry component, you can just include a dummy file that your application doesn't need, but you need to force that component to get reinstalled.  If the component gets reinstalled, the registry data will be updated.

0 Kudos