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> ...
Get WiX: A Developer's Guide to Windows Installer XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.