View Full Version : Need help to permanently set a registry key value (no uninstall)

02-29-2008, 12:29 PM
Hi everyone,

I'm new to this forum, and fairly new to IS. I have a special requirement where I want to set a registry at install time permanently - it should never be removed at install time. The value I'm setting (ie. not creating, it's already created I'm just setting it to a desired value) is the Start key value for a windows system service (msdtc.exe). The install works fine, the system service is set to the correct start mode (Automatic), but when we uninstall the application the Start value is deleted from the registry Key. This makes the service itself appear to have been uninstalled and no longer appears in Services.msc. I would like to prevent this uninstall behavior.

I've tried two approaches:
1) Use the Registry View to set the registry key value in question. I have tried to Install Only(+) option, but the menu item is always grayed out for me (all other options, such as uninstall entire key, Install if absent, Uninstall if Present and Automatic are all enabled). So for what ever reason, I can't use this approach.
2) I added some install script to call RegDBSetKeyValueEx() which works fine for the install, but again removes the key value at uninstall time.

There must be a way to set a registry key and forget about it, no?

I'm using InstallShield 2008 and it's an InstallScript MSI project. Any suggestions would be greatly appreciated.

03-02-2008, 05:30 AM
maby someone from the installshield support team can help us??????????????????????????

03-02-2008, 11:03 PM
If you disable logging, InstallShield doesn't keep track of what you're doing so it won't undo it during an uninstallation.



I used this to modify a system's PATH statement. Like you, everything worked fine during the installation, but during the un-install, the entire path statement would disappear.

But, I'd also like to hear if there's a 'correct' way to do this.


03-03-2008, 10:40 AM
Another way to do this is to create a seperate component specifically for your registry entry (use setup design view) create the registry key under the component, and set the component's permanent flag to 'Yes'.

03-03-2008, 11:36 AM
Okay, thanks guys, I'll give that a shot right away!

03-03-2008, 02:22 PM
Ok, got it working. The way I fixed it, I created a new component with the Permanent attribute set. That corrected it. Simple. Now why didn't I think of that?!?

Well, thanks again for the help.

03-04-2008, 03:00 AM
or how can i decide if to remove these reg key when uninstaling...by user choice?

03-11-2008, 09:38 AM
You can ask the user the question when the finish dialog appears. If they select the delete option then use a modification of Leigh's code:

if( bvOpt1 ) then
Disable( LOGGING );
nResult = RegDBGetKeyValueEx( ... );
if( nResult = 0 ) then
RegDBDeleteValue( .... );
Enable( LOGGING );