NayanPatel
Posts: 3
Joined: Mon Jan 05, 2009 7:44 pm

How to avoid overwrite of Registry Key if exists

Hi,

I want to create a simple registry key value as below (string) only if its not found or data is empty.
Path : HKEY_LOCAL_MACHINE\Softwares\MyApp
Value Name : AppConfig
Data: XXXYYYZZZ

Sounds like a simple thing but I cant find any option in setup editor.

When I use Add New Value dialog it shows me Append, Prepend and Overwite options but there is no way I can skip overwite if value already present. I have written VB Script custom action for this but I really want to avoid VBScript custom action if I can use inbuilt Registry features. I found on msdn that Microsoft do not recommand VB Script Custom action.

Side note: I also dont want to delete this value during uninstall... ( I did this by doing Right click on MyApp Key -> Properies and uncheck "Delete on uninstall" option)

Thank you in advanced.
Nayan Patel
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to avoid overwrite of Registry Key if exists

Hi,

In order to find a registry value you can use a Search. The name of the search is actually an installer property which can be used in the install process. With it, you can condition the component of the registry value in the Organization page.

For example, if the search is named MY_REG_VALUE, the condition for the component can be:

Code: Select all

NOT MY_REG_VALUE
This way the component will be installed only if the search didn't find anything.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Nitro40
Posts: 1
Joined: Fri Sep 12, 2008 2:39 pm

Re: How to avoid overwrite of Registry Key if exists

Cosmin,

Could the option of "do not overwrite" be added as an option in a future build? I have seen this in other installer packages, and would simplify building these installs.

Thanks,
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to avoid overwrite of Registry Key if exists

Hi,

Please note that the components in the Organization page can use the Never Overwrite attribute. However, this refers to future packages which will try to overwrite the component, it doesn't refer to resources already installed on the machine.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”