Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameterise Service start option in WiX installer

I have a ServiceInstall component in a WiX installer where I have a requirement to either start auto or demand depending on parameters passed into the MSI.

So the Xml element in question is

<ServiceInstall Vital="yes"
     Name="My Windows Service"
     Type="ownProcess"
     Account="[SERVICEUSERDOMAIN]\[SERVICEUSERNAME]"
     DisplayName="My Service"
     Password="[SERVICEUSERPASSWORD]"
     Start="demand"
     Interactive="no"
     Description="Something interesting here"
     Id="Service"
     ErrorControl="ignore"></ServiceInstall>

WiX will not allow using a PArameter for the Start attribute, so Im stuck with completely suplicating the component with a condition, eg/

<Component Id="ServiceDemand"
                 Guid="{E204A71D-B0EB-4af0-96DB-9823605050C7}" >
        <Condition>SERVICESTART="demand"</Condition>    
...

and completely duplicating the whole component, with a different setting for Start and a different Condition.

Anyone know of a more elegant solution? One where I don;t have to maintain 2 COmponents whjich do exactly the same thing except the Attribute for Start?

like image 446
Jamiec Avatar asked Mar 23 '10 13:03

Jamiec


1 Answers

The Start field in the ServiceInstall table isn't formatted so what you are putting in with a property will not work. This link has some helpful suggestions that might get you through it: ServiceInstall - Start element. Looks like the person who posted had the same issue. My favorite suggestion they provide is to create a custom action that runs before InstallServices action that will change the value of the Start element in the Service Install table.

Update: Modified the link to the suggested site.

like image 75
Scott Boettger Avatar answered Oct 01 '22 04:10

Scott Boettger