Installing a Windows Service

by Markus 2. November 2009 21:17

 

Installing a Windows Service

This is a real fun thing in WiX, because it is very simple and strait forward.

 

Step 1

Insert the Following Code: (In Product.wxs or in a Fragment)

<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
….

<Component Id='PTTesterService' Guid='c219dabd-f46d-4bff-91a9-00d85a7eb3d3'
           SharedDllRefCount='no' KeyPath='no' NeverOverwrite='no' Permanent='no'
           Transitive='no' Win64='no' Location='either'>

  <File Id='TheTesterService.exe' Name='TheTesterService.exe' Source='..\bin\$(var.Configuration)\TheTesterService.exe'
        ReadOnly='no' KeyPath='yes' Vital='yes' Hidden='no' System='no'
        Checksum='no'  />

  <ServiceInstall Id='TheTesterServiceInstall' DisplayName='TheTesterService' Name='The Tester Service'
                  Description ='Description of TheTester Service...'
                  ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes'
                  Account='NT AUTHORITY\LocalService' />
  <ServiceControl Id='TheTesterServiceControl' Name='TheTesterService'
                  Start='install' Stop='uninstall' Remove='uninstall' />

</Component>

…..

</DirectoryRef>

 

Notes:

  • The Directory Ref is defining Where to install the Service Files.
  • Setting the Account to 'NT AUTHORITY\LocalService' is important for Windows 7 and probably later OS. Because Windows 7 is not allowing the Service to be installed with LocalSystem which would be the default

 

 

Step 2

Define in which Feature to install the Service:

 

<Feature Id="DefaultFeature" Title="PTTester" Level="1"  ConfigurableDirectory ="APPLICATIONROOTDIRECTORY">
   ….

  <!--Installing the Services-->
  <ComponentRef Id="PTTesterService"/>

   …….

</Feature>

 

<= Back to Content

Tags: ,

Comments

11/2/2009 9:17:34 PM #

trackback

Home - Wix

Home - Wix

Blog of MaHop.net |

About MaHop.Net

Just look on our Webpage http://www.mahop.net

Tag cloud