4

I have a WiX script, that does installation of service. I have following ServiceInstall element under Component.

<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes"
                Name="abc" DisplayName="abc service"
                Description="It does this" Start="auto"
                Account="LocalSystem" ErrorControl="normal" Interactive="no">
  <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall ="yes" />
</ServiceInstall>

And as seen from the code, I am using ServiceConfig with DelayedAutoStart flag to set the service to start in delayed auto start mode. However the WiX compiler (candle.exe) triggers a warning:

warning CNDL1150: ServiceConfig functionality is documented in the Windows Installer SDK to "not [work] as expected." Consider replacing ServiceConfig with the WixUtilExtension ServiceConfig element.

Hence, I tried using util:ServiceConfig^, however this element doesn't have any attribute to control service startup.

^ Namespace import:

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
  xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 

Hence, the questions are simply:

  1. How to set service startup to be Automatic (Delayed Start)?
  2. How to conditionally do it only on Vista and above, and do normal (Automatic) on Windows XP/2003?
Ajay
  • 18,086
  • 12
  • 59
  • 105

2 Answers2

6

After checking the source it does not seem possible at the moment. Wix calls the ChangeServiceConfig2 function only with the SERVICE_CONFIG_FAILURE_ACTIONS parameter and not with SERVICE_CONFIG_DELAYED_AUTO_START_INFO.

If I was you, I'd write a custom action calling sc config abc start=delayed-auto in a CMD.

As for your second question add VersionNT version condition (VersionNT >= 600 for all version greater than Vista)

ChristianMurschall
  • 1,621
  • 15
  • 26
  • 2
    Then ideally it shouldn't give that warning. – Ajay May 16 '17 at 05:33
  • Downvoted because the source code linked to is for WIX's `UtilExtension` `` element (with the `FirstFailureActionType` attribute) and not the original MSI `` element (with the `DelayedAutoStart` and `OnInstall` attributes) – Dai Oct 16 '18 at 07:13
  • 2
    Thanks for the downvote @Dai. However, the OP does use the UtilExtension, and as you can easily see, candle.exe triggers a warning when using ServiceConfig as also documented by the OP. I gladly accept a downvote, but please also be so kind and offer a better answer to the OPs problem. – ChristianMurschall Nov 16 '19 at 08:40
  • Does anyone know this issue has been resolved in the latest release? – Stanley Chen Aug 17 '21 at 15:50
  • I found a replacement in this https://stackoverflow.com/questions/3763596/how-to-change-the-windows-service-startup-type-in-a-wix-installer mentioned as below, not sure if it is a fixed. – Stanley Chen Aug 17 '21 at 16:05
  • 1
    `` works as expected here, my service is installed as delayed auto start – David Heffernan May 17 '22 at 08:11
  • @DavidHeffernan: are you using the one from `http://schemas.microsoft.com/wix/UtilExtension`? Cause that is what caused the warning in the OPs question. – ChristianMurschall May 17 '22 at 13:18
  • 1
    @ChristianMurschall No, because `util:ServiceConfig` doesn't support `DelayedAutoStart`. So both I and the asker are using the standard WiX `ServiceConfig`. – David Heffernan May 17 '22 at 13:53
0

Yes the vanilla ServiceConfigworks , Infact i am using both ServiceConfig,(from utils and from wix) inside a service

<util:ServiceConfig
          
        FirstFailureActionType="restart"
        SecondFailureActionType="restart"
        ThirdFailureActionType="restart"
        RestartServiceDelayInSeconds="0"
         
     />
    <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall ="yes" />