Using WiX to install and start a Windows Service as part of your Add-In install is fairly easy. The only thing you really have to watch out for is the KeyPath value for your service executable; it has to be set to yes, while all other file KeyPaths must be set to no.

Make sure you also use your own GUID values for UpgradeCode and Component ID values.

This code works with the latest WiX 3.0 weekly build.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="">
    Name="Windows Home Server Disk Management Add-In"
    Manufacturer="Sam Wood - Tentacle Software"
      Manufacturer="Sam Wood - Tentacle Software"
      Compressed="yes" />

    <Media Id="1" Cabinet="" EmbedCab="yes" />

    <Property Id="WHSLogo">1</Property>

    <Condition Message="[ProductName] requires Windows Home Server. For more information, please refer to the User Guide.">VersionNT = 502</Condition>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="WHS" Name="Windows Home Server">
          <Component Id="HomeServerConsoleTab.DiskMgt" Guid="{908B7199-DE2A-4dc6-A8D0-27A5AE444FEA}">
            <File Id="HomeServerConsoleTab.DiskMgt.dll" Name="HomeServerConsoleTab.DiskMgt.dll" Source="..\HomeServerConsoleTab.DiskMgt\bin\Release\HomeServerConsoleTab.DiskMgt.dll" Vital="yes" KeyPath="no" DiskId="1"/>
            <File Id="DiskMgt.Common.dll" Name="DiskMgt.Common.dll" Source="..\DiskMgt.Remotable\bin\Release\DiskMgt.Common.dll" Vital="yes" KeyPath="no" DiskId="1"/>
            <File Id="DiskMgt.Service.exe" Name="DiskMgt.Service.exe" Source="..\DiskMgt.Service\bin\Release\DiskMgt.Service.exe" Vital="yes" KeyPath="yes" DiskId="1"/>
              DisplayName="Windows Home Server Disk Management"
              Description="Monitoring and management service for Windows Home Server Disk Management Add-In"
              <ServiceDependency Id="QSM"/>
              <ServiceDependency Id="pdl"/>
              <ServiceDependency Id="WHSTransportService"/>
            <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="DiskManagement" Wait="yes" />

	<Feature Id="ProductFeature" Title="WHSDiskManagement" Level="1">
      <ComponentRef Id="HomeServerConsoleTab.DiskMgt" />

ServiceDependency values are the real names for the services your code depends on. You can find the Service Name by opening services.msc and checking the properties for the specific service.

The ServiceControl node allows you to start and stop services during install and uninstall.

In the example above, I’m controlling a service called DiskManagement (the service I’m installing in the parent ServiceInstall node, but it could be any service). The service is started after the MSI package has been installed, stopped (if it’s started, to allow me to overwrite or delete the service’s files) at the beginning of both install and uninstall operations, and removed at the end of an uninstall operation.

The Service Control Id value is just an identifier that you can use to refer to this specific ServiceControl node in other places in the XML.

If you want to use extended character sets (for localization into different languages, usually) in the various display and description fields, you’ll need to set the xml encoding value and Product Codepage appropriately. I’ve also set the Product Language and Package Languages to German in this example:

<?xml version="1.0" encoding="Windows-1252"?>
<Wix xmlns="">
    Name="Windows Home Server Datenträger-Verwaltung"
    Manufacturer="Sam Wood - Tentacle Software"
      Manufacturer="Sam Wood - Tentacle Software"
      Compressed="yes" />

There’s some good documentation on the rest of the options (ownProcess, Start type, Account etc.) in the WiX help files that get installed along with the WiX binaries. It’s not the most friendly set of technical docs I’ve seen, but it does give detailed descriptions of the individual configuration elements.

posted on Thursday, January 01, 2009 2:22 PM | Filed Under [ Windows Home Server Development ]


Site Sections

Recent Posts


Post Categories

WHS Add-In Tutorial

WHS Blogs

WHS Development