下面XML代碼展示如何利用Wix中的ServiceInstall來自動安裝Windows服務
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="832B8322-6349-4ddd-8AC6-CF18E7A05509" Name="DotNetService"
Language="1033" Version="1.0.0.0" Manufacturer="Persistent"
UpgradeCode="6493A097-BA2D-482b-9EDD-2BDBC3E5463E">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="WixServiceInstaller.cab" EmbedCab="yes" />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='DOTNETSERVICE' Name='DotNet'>
<Component Id="InstallService" Guid='AAA67783-EEF0-453f-BBAF-E02B1341E3BC'>
<File Id="WindowsService" Name="WixServiceInstaller.exe"
Source="WixServiceInstaller.exe" KeyPath="yes"/>
<ServiceInstall Id="ABC"
Name="WixServiceInstaller"
DisplayName="WixServiceInstaller"
Type="ownProcess"
Start="auto"
ErrorControl="normal"
Description="WixServiceInstaller"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]" />
<ServiceControl Id="StartWixServiceInstaller"
Name="WixServiceInstaller" Start="install" Wait="no" />
<ServiceControl Id="StopWixServiceInstaller" Name="WixServiceInstaller"
Stop="both" Wait="yes" Remove="uninstall" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id='TheOnlyFeature' Description='Feature contains the single component'
Level='1'>
<ComponentRef Id='InstallService'/>
</Feature>
</Product>
</Wix>
--------------------------------
from:http://avinashkt.blogspot.com/2007/05/how-to-install-windows-service-using.html