Reputation: 1597
I have an MSI installer that installs a Service and by default it is stopped. The user can manually turn it on or leave it stopped. I also have a Patch for the MSI.
Problem: When installing the Patch, the service is stopped. I would like the Patch to leave the Service ON if it was ON, and OFF if it was OFF. How can i achieve this funcionality?
Upvotes: 1
Views: 533
Reputation: 1597
So in the end i used two Custom Actions. One that saves the status of the services prior to installing the Patch. I used properties like MYSERVICE_STATUS
setting them to "0" if the services are STOPPED
and "1" if they are RUNNING
.
After the Patch installation finshes, i launch another Custom Action that checks these properties and the final state of each Service. If MYSERVICE_STATUS == 1
and the Service is now STOPPED
them, i restart it.
Upvotes: 0
Reputation: 32280
As far as I understand the way patching works, this is expected default behavior.
Look, when you install the MSI package the first time (initial installation), the service is installed as stopped and the MSI package is cached in a special place on your system. When you install a patch, the changes patch brings to your installation package are applied to the cached MSI, thus transforming it the desired way, and the package is re-installed. Hence, as long as the initial package contains instructions to install the service as stopped, and the patch changes don't modify this, the component is re-installed and the service ends up being stopped - just as right after the initial installation.
In order to change this behavior, you can try to mark the component which contains the service as NeverOverwrite
. If you set NeverOverwrite='yes'
for a component, it is not re-installed during patch application, hence the existing service is left alone and it stays in a state it was before the patch is applied.
I'm not sure whether you need to change the component the described way in the initial installation package. Hope, changing it in the newer one will work. Otherwise, this could be an issue if you already shipped the initial version of the product.
I should warn you that I didn't try this exact scenario, so you might want to verify this suggestion first.
Upvotes: 2