cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Glaucus
Level 3

Need help to permanently set a registry key value (no uninstall)

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.
Labels (1)
0 Kudos
(7) Replies
Donimoni
Level 3

maby someone from the installshield support team can help us??????????????????????????
0 Kudos
lmoulder
Level 3

If you disable logging, InstallShield doesn't keep track of what you're doing so it won't undo it during an uninstallation.

Do...

Disable(LOGGING);
RegDBSetKeyValueEx(....);
Enable(LOGGING);


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.

Leigh
0 Kudos
ARobinson
Level 3

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'.
0 Kudos
Glaucus
Level 3

Okay, thanks guys, I'll give that a shot right away!
0 Kudos
Glaucus
Level 3

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.
0 Kudos
Donimoni
Level 3

or how can i decide if to remove these reg key when uninstaling...by user choice?
0 Kudos
MarkEarle
Level 6

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 );
RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
nResult = RegDBGetKeyValueEx( ... );
if( nResult = 0 ) then
RegDBDeleteValue( .... );
endif;
Enable( LOGGING );
endif;


Cheers,

ME
0 Kudos