aloukissas
aloukissas

Reputation: 11

WiX: start service on install but not on major upgrade

For certain reasons, I would like to have the service that gets installed with my installer to be automatically started only when this is a fresh install but not when upgrading. It looks like the ServiceControl Element doesn't allow such fine granularity.

My current code looks like this:

<ServiceControl Id="StartService" Start="install" Stop="both" Remove="both" Name="MyService" Wait="no"/>

Is there a way to achieve this? Perhaps using a CustomAction instead of the ServiceControl element?

Upvotes: 1

Views: 681

Answers (2)

PhilDW
PhilDW

Reputation: 20780

If you've already shipped the previous MSI version then it's too late to add a condition to the StartServices action - UPGRADINGPRODUCTCODE is used in the older setup being upgraded, not the newer incoming one. In any case, during an upgrade you want a condition in the newer upgrade install, because that'll be the one actually starting the services, not the old one being uninstalled. You need the "OLDERPRODUCTFOUND" or equivalent property in the upgrade info for your new install that is set when an older version is detected, and use that in a condition. Note that StartServices applies to all services, not just a single one, so if you don't want this behavior for all your services you'll need another solution.

Upvotes: 1

IlirB
IlirB

Reputation: 1430

You could try putting a condition on the StartServices custom aciton, for example:

  <InstallExecuteSequence>
   <StartServices Sequence="5900">
      <![CDATA[VersionNT AND NOT UPGRADINGPRODUCTCODE]]>
    </StartServices>
  </InstallExecuteSequence>

I haven't tested this exact condition, particularly UPGRADINGPRODUCTCODE, but i use a different condition on the same custom action (StartServices) for my own purposes and it works perfectly.

Upvotes: 1

Related Questions