mctozzy
Posts: 81
Joined: Wed Feb 14, 2007 7:37 am

Applying patch is changing service start type

Mon Apr 28, 2008 7:08 am

Scenario:

1. Base install package installs a service and sets the start type to "Automatic".
2. User changes service start type to "On demand" (manual) through control panel.
3. Apply a patch. Service start type reverts to "automatic".

I sort of understand why this happens, but how can we ensure that if the service is already installed that we don't 're-install it' or change any of it's parameters? For example, customer may change the service account name and password - definitely would not want this to be changed in the process of applying a patch?

Thanks,
mctozzy

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

Re: Applying patch is changing service start type

Tue Apr 29, 2008 9:19 am

Hi,

When applying a Windows Installer patch, the settings in the Upgraded package will always be used over the settings made on the machine. If you want to avoid this behavior you can follow these steps:
- go to the Search page and create a search for the main executable of the service
- go to the Organization page and use the property of the search to condition all the components which will affect the service

This way, the components which contain resources that modify the service will not be installed.

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

mctozzy
Posts: 81
Joined: Wed Feb 14, 2007 7:37 am

Re: Applying patch is changing service start type

Tue Apr 29, 2008 9:33 am

I sort of understand the technique you propose...but not quite completely. Suppose that my patch updates the service exe to a newer version, but I don't want the installer to change the service's registry entries, such as the start type, user account and password if the service has already been created. I don't see how a conditional variable used with the Organisation of the features solves this problem...because the service details seem to be tied to the feature that installs the EXE? (Unless I deliberately base the service creation on another feature which is itself based on a search for something like the service registry entry)?

Also, I still want repair to create the service in the registry if it has got "lost", overriding the functionality as above.

Thanks...

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

Re: Applying patch is changing service start type

Tue Apr 29, 2008 3:55 pm

Hi,
I don't see how a conditional variable used with the Organisation of the features solves this problem...because the service details seem to be tied to the feature that installs the EXE?
An installation package is organized into Components and Features. The installation of a component can be conditioned directly with a property, however this is not always true for features. By conditioning a component, the component will not be installed by Windows Installer if the condition is not met.

I'm afraid that you cannot partially update a service. When a patch is applied, Windows Installer triggers a repair of the target package and the service settings are restored to the original values. After this step, the patch evaluates the differences between the installed package and the resources it contains and updates the old installation.

If you want to update the service and still keep some of its settings, the only solution is to use a custom action. This custom action can have two functions:
- the first function memorizes the service settings before the patch is applied
- the second function replaces the settings made by the patch with the one memorized before the patch was applied
I still want repair to create the service in the registry if it has got "lost", overriding the functionality as above.
Please note that the settings of the service are written inside the MSI file, not in the registry. When the MSI package is installed the service will be created and configured based on the tables inside the MSI. Therefore, what you need can be done only through a custom action conditioned to run only during repair.

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

mctozzy
Posts: 81
Joined: Wed Feb 14, 2007 7:37 am

Re: Applying patch is changing service start type

Wed Apr 30, 2008 12:12 pm

cosmin wrote:If you want to update the service and still keep some of its settings, the only solution is to use a custom action. This custom action can have two functions:
- the first function memorizes the service settings before the patch is applied
- the second function replaces the settings made by the patch with the one memorized before the patch was applied
OK I guess I can see how to do that...although I must say it seems a bit odd that I have to do this...surely it is a common scenario patching a service exe and not wanting to disturb the service settings?

Alternatively, I assume that if I set up the service parameters (start type, user account and password) as installer variables passed through on the command line when the original install was done, that if I do the same when applying the patch that should also work? (Except that it relies on the user to remember those details)

Please note that the settings of the service are written inside the MSI file, not in the registry. When the MSI package is installed the service will be created and configured based on the tables inside the MSI. Therefore, what you need can be done only through a custom action conditioned to run only during repair.
Yes that's true, except that I create the service using installer variables for those parameters so that they are not "hard coded" in the msi file. At least that offers the scope to pass them through again when the patch is applied as above. But Repairing is another matter...I can't really see a way around the fact that after the repair, (unless that was also done from the command line too...) the user will have to reset the service parameters.

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

Re: Applying patch is changing service start type

Wed Apr 30, 2008 12:48 pm

Hi,
surely it is a common scenario patching a service exe and not wanting to disturb the service settings?
I'm afraid that this is not supported by Windows Installer.
I assume that if I set up the service parameters (start type, user account and password) as installer variables passed through on the command line when the original install was done, that if I do the same when applying the patch that should also work?
Yes, the installation package can use installer properties for the username and password of the service. These properties can be written into the registry and retrieved by searches in the upgraded package. However, this cannot be done for the start type of the service.
But Repairing is another matter...I can't really see a way around the fact that after the repair, (unless that was also done from the command line too...) the user will have to reset the service parameters.
Please note that this is the recommended approach. If the user configures the service incorrectly he should be able to repair it in order to restore the default settings.
However, you can use searches in the target package to retrieve the values of your custom properties from the registry. This way, when a repair is triggered the service will use the settings stored in the registry.

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

mctozzy
Posts: 81
Joined: Wed Feb 14, 2007 7:37 am

Re: Applying patch is changing service start type

Wed Apr 30, 2008 12:52 pm

OK Thanks Cosmin.

mctozzy
Posts: 81
Joined: Wed Feb 14, 2007 7:37 am

Re: Applying patch is changing service start type

Fri May 02, 2008 12:14 am

I did some more experiments with this...it would seem that once the initial service is created by the installer, there is absolutely no way to cause the service's user account and password (at least on Win 2003) to be changed, whether repairing or patching. Either the user has to do it manually, or you have to remove and reinstall. i.e If user changes it and then you repair, it does not get reset back to what it was at time of installation.

spike0xff
Posts: 3
Joined: Fri May 09, 2008 8:32 pm

Re: Applying patch is changing service start type

Fri May 09, 2008 10:05 pm

Hi Cosmin - I too am searching for a way to protect the values of certain registry entries during an upgrade, while still deleting them in a full uninstall.
I understand that I can, in theory, do this using custom actions.
I feel, as other customers do, that this seems like a bizarrely large effort for something that sounds simple and is a common request. If *we* can do it using your tools, why can't you do it using.. your tools? What I think we'd all like is a checkbox on each registry item that says "if this entry exists, keep the old value". Couldn't AI just generate custom actions to take care of this? I think it could save a lot of your customers significant time & frustration...
Surely compared to dozens (hundreds?) of customers all learning how to create and use custom actions, then writing and debugging custom actions, all to solve essentially the same problem and therefore almost all redundant effort, it is more efficient for somebody like you who already knows how to do it in his sleep, to do it just once?

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

Re: Applying patch is changing service start type

Mon May 12, 2008 12:31 pm

Hi,
I too am searching for a way to protect the values of certain registry entries during an upgrade, while still deleting them in a full uninstall.
This can be done by using the "Never Overwrite" attribute for the components of the registry entries. If this attribute is set before the component is installed, the component will not be overwritten if it already exists (by a patch for example). Note that this will not work for an upgrade because the old component is uninstalled and then the new one is installed.

Another approach is this:
- go to the Search page and create a search for the registry key you need
- use the result of this search to condition the installation of the components of the registry entries

If the property is empty then the registry key was not found and the components should install. If the property has a value then the registry key was found and there is no need to install the component.
What I think we'd all like is a checkbox on each registry item that says "if this entry exists, keep the old value". Couldn't AI just generate custom actions to take care of this?
We will consider including this feature in a future version of Advanced Installer. Thank you for your suggestion.

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

digocesar
Posts: 38
Joined: Thu Dec 03, 2015 12:26 pm

Re: Applying patch is changing service start type

Mon Jan 04, 2016 6:12 pm

Hi.
I'm needing to keep Service Start Type too.
Was created some easier way to configure this since 2008?

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Applying patch is changing service start type

Tue Jan 05, 2016 11:53 am

Hello,

I'm afraid not. You can try to use the same workaround as explained above.

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

Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Applying patch is changing service start type

Thu Feb 28, 2019 3:50 pm

Is there any way to use SecureProp (https://www.advancedinstaller.com/user- ... y-net.html) to read the password value and pass it to the public property so it can be used during a repair or upgrade of a Windows Service so that the the service account value can be restored?

Catalin
Posts: 6542
Joined: Wed Jun 13, 2018 7:49 am

Re: Applying patch is changing service start type

Mon Mar 04, 2019 4:12 pm

Hello Collins,

"SecureProp" is indeed used to read the values of secured properties from C++, C#, VB.NET and Java applications. If you want to store the read value in a property, you can have a look on our "How to set an installer property using custom actions" article. However, after doing so, the password will appear in the log file, which no longer makes sense of using the "SecureProp" in the first place.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Collins
Posts: 138
Joined: Wed Oct 12, 2016 2:57 pm

Re: Applying patch is changing service start type

Mon Mar 04, 2019 5:32 pm

Thanks Catalin,

Unfortunately that doesn't explain how I can use this functionality because the example provided is for an external application and not within the installer itself. From the documentation I see that the Secure Property dll (SecureProp.dll) is used along with an internal custom action and I have no way of seeing how it works or how to use it within the installer itself. I don't need to integrate it into an external application.

What I want to be able to do is use the internal custom action and to read that encrypted value (with another internal custom action) and then place it into the public property so the installer can use the value again, all within the installer; the same way you would set installer property.

As for the value appearing in the log, once the secure property attribute is selected, the hide property value is automatically set as well, which should mask it in the logs.

Return to “Common Problems”