bvelke
Posts: 67
Joined: Fri Jun 10, 2011 6:36 am

Don't overwrite registry

If a certain registry key (REG_SZ) doesn't already exist, then I want it to be installed with a specified value.

But if the key does exist, then I want the existing value to be retained. That is, I don't want to prepend, append, or replace the existing value - but those seem to be the only options that are available to me.

How can I preserve an existing value?

Thanks.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Don't overwrite registry

Hello,

Here are the steps to accomplish this:
  • go to the Search page and create a new search
  • use the "Add Location" context menu to add the Registry as the search location
  • add your key's information
  • go to the Registry page and add the key in the intended location
  • press F8 while the registry key is selected( this will identify the registry key's component in the Organization page )
  • add the search name as the component's condition
This way the installer will perform a search for your registry key at the beginning of the installation and install its component only if it is not already present on the target machine.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bvelke
Posts: 67
Joined: Fri Jun 10, 2011 6:36 am

Re: Don't overwrite registry

Thank you for the response.

Upon finding the Component Properties screen, it occurs to me to ask -- what's the difference between the Search strategy you outlined and merely checking the "Never overwrite" box?

Thanks again.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Don't overwrite registry

Hello,
what's the difference between the Search strategy you outlined and merely checking the "Never overwrite" box?
Never Ovewrite : The component is not installed or reinstalled, if a key path file or a key path registry entry for the component already exists. This setting would apply in case of an upgrade( component is detected by its GUID on the local machine ). This affects only future installers which try to overwrite the component key path, it doesn't affect already installed resources.
Above Search : The component is not installed only if found on the hard drive( component is installed if registry is found in the search location ).

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
invalidptr
Posts: 79
Joined: Thu Nov 18, 2010 7:10 pm

Re: Don't overwrite registry

I got bit by this tonight. Amazed that "Never Overwrite" and "Permanent" don't allow the case of "Doesn't Exist". "Never Overwrite" should be re-written "Never Write or Overwrite" since that is more accurate. The error I was getting is "Could not open key: UNKNOWN32\Software\Your Co\Your App. Verify that you have sufficient access to that key, or contact your support personnel."
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Don't overwrite registry

Hello,

This error may appear if you have enabled the "Never Overwrite" option for a component which contains as a key resource a registry.

Please keep in mind that Windows Installer will not install a component if the following conditions are true:
1. The component key resource is a registry.
2. The component has the "Never Overwrite" option enabled.

So, it is not recommended to enable the "Never Overwrite" option for a component which contains as a key resource a registry. If you want to enable the "Never Overwrite" option for a component which contains as a key resource a registry then you can add a dummy file as a key resource for the related registry component.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
invalidptr
Posts: 79
Joined: Thu Nov 18, 2010 7:10 pm

Re: Don't overwrite registry

add a dummy file as a key resource for the related registry component.
Could you explain this further please. Are we talking about a file in my setup? Or a windows file?
invalidptr
Posts: 79
Joined: Thu Nov 18, 2010 7:10 pm

Re: Don't overwrite registry

mihai.petcu wrote:* add the search name as the component's condition
Note to future self: This is the all-caps name next to magnifying glass and should be used like PRINTERCONFIG = "" in the condition.
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Don't overwrite registry

Hello,
Could you explain this further please. Are we talking about a file in my setup? Or a windows file?
Sure, I mean that you can add a dummy file in your installation project in "Files and Folders" page. Then, from "Organization" page, you should set the dummy file as a key resource for the your registry component which has the "Never Overwrite" option enabled.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”