Ajay
Ajay

Reputation: 18411

Configure service to Delayed Auto-Start (and Auto-start on XP/2003)

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?

Upvotes: 4

Views: 3406

Answers (2)

madhusudhan samantray
madhusudhan samantray

Reputation: 54

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" />

Upvotes: 0

ChristianMurschall
ChristianMurschall

Reputation: 1671

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)

Upvotes: 7

Related Questions