wixwindows-servicescustom-action

Wix - schedule custom action between StopServices and StartServices


I would like to add a custom action in my Wix installer that runs between the StopServices and the StartServices. So that the service is down when the custom action is running. If I do the following the action runs before the StartServices, but also before the StopServices.

<Custom Action="IisRewriteRules" After="StopServices" Before="StartServices"> NOT REMOVE~="ALL" </Custom>

It seems that I can't add both a Before and After tag, that gives following error:

Error CNDL0035: The Custom/@After attribute cannot be specified when attribute Before is present. (20)

Is there some way I can achieve this? As a backup I guess I could stop the service in my custom action and restart it again at the end of the custom action, but I would prefer to not have to do that.

Looking online I couldn't really find anything. Is there maybe a way to schedule the ServiceControl?


Solution

  • I found in the Wix Docs that you can add a Sequence tag instead of Before or After. You can pass this an integer value and schedule it between the default actions. Following page shows the default actions and their corresponding Sequence value: Suggested InstallExecuteSequence