1
votes

I use WIX for installing an application & a service,

If I install the service for the first time, I want it to be "disabled" and that works fine by setting the field Start="disabled" in the serviceInstall element.

If I install (upgrade) the service while it is already installed on the computer and is set to "Automatic", I want the service to be "Automatic" after the upgrade too, and I can't get this behaviour, The service is upgraded and set as "disabled".

I tried to do this by using 2 serviceInstall element, in one of them Start="disabled" and in the other Start="Auto".

I added a condition to each of my serviceInstall that asks if the service is installed already.

I guess my conditions are not good....

What is the best way for this?

Thanks a lot

1

1 Answers

0
votes

I recently encountered a similar problem as well, and the way I approached it is using custom actions after the install. It'll look something like this:

<CustomAction Id="SetStartUpType" BinaryKey="CA.SetStartUpType" DllEntry="CustomAction" Execute="immediate" Return ="check"/>
<Binary Id="CA.SetStartUpType" SourceFile="../WixCustomAction/bin/$(var.BUILD)/WixCustomAction.CA.dll" />

<InstallExecuteSequence>
  <Custom Action='SetStartUpType' After='InstallFinalize'>Installed</Custom>
</InstallExecuteSequence>

Setting the custom action condition to "Installed" makes sure that it only changes the startup type if it is already installed. So in your wix file you probably just need one serviceinstall element with start="disabled" for the first install to be disabled.

And thanks to Peter Kelly, there is a way to manually change the service startup types and start the services (if you wish) in your custom actions file. Details can be found here