- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Registry component best practices: Property values in registry reset after patch
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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:
- you have a component that creates a registry key: HKLM\SOFTWARE\My Company\TestDirectory
- the value of TestDirectory is a String Value from a property called [TESTDIRECTORY] with a default value of "C:\Foo"
- 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.
- Now I create an update patch.
- I launch the patch manually without passing any values to it.
- 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?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Scott,
You don't need the custom action and you don't need the TESTDIRECTORY_TEMP property. Just do the following:
- In the Property Manager, have an entry for TESTDIRECTORY and give it the default value you want
- 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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Scott,
You don't need the custom action and you don't need the TESTDIRECTORY_TEMP property. Just do the following:
- In the Property Manager, have an entry for TESTDIRECTORY and give it the default value you want
- 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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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.
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)