Historical Note

This page was migrated from the original p-nand-q.com site which was last updated in 2015. The content has been preserved exactly as it was, with only formatting updated for modern browsers. Over the coming days and weeks, the content will be reviewed and may be updated for accuracy and relevance. If you find any issues, please contact me.

Creating Services with WiX

Overview

Creating a service is actually fairly easy and straightforward. No, really, it is actually quite good, especially because you can guarantee that your service is running after the setup, and gets shutdown before uninstall. You only need to have an existing file component that is the main executable of your service. The rest is a piece of cake:

Example:

Let's say I have this fine file:

<Component Id='bin_paserver_exe' Guid='YET ANOTHER GUID GOES HERE'>
        <File Id='bin_paserver_exe_file' Name='PASERVER.EXE' DiskId='1' Source='BIN\PASERVER.EXE' Vital='yes'/>
        ...
    </Component>

All you need to add its two tags, like this:

<Component Id='bin_paserver_exe' Guid='YET ANOTHER GUID GOES HERE'>
        <File Id='bin_paserver_exe_file' Name='PASERVER.EXE' DiskId='1' Source='BIN\PASERVER.EXE' Vital='yes'/>
        <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" Name="PASERVER" DisplayName="ProAKT Server" Start="auto" Account="LocalSystem" ErrorControl="ignore" Interactive="no"/>
        <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="PASERVER" Wait="yes" />
    </Component>

Both are pretty much self explaning, but if you insist, the reference documentation is here: