Starting, stopping, and uninstalling a service
The ServiceInstall
elements works well for installing a service, but doesn't provide a way to start, stop, or uninstall one. For that, you'll use the ServiceControl
element. It can be added to the same component as the ServiceInstall
element thereby sending signals to the testsvc
you're installing.
The following example starts the service during install and stops and removes it during uninstall. These actions happen during the deferred
stage of the Execute sequence.
<DirectoryRef Id="INSTALLLOCATION"> <Component ... > <File ... /> <ServiceInstall ... /> <ServiceControl Id="sc_WindowsService1" Name="testsvc" Start="install" Stop="both" Remove="uninstall" Wait="yes" /> </Component> </DirectoryRef>
The Name
attribute specifies the service that you want to control. Start
, Stop
, and Remove
can each be set to one of the following...