Answer
Windows Installer does not offer support for detecting a service on the target machine. However, in Advanced Installer this can be done through a predefined custom action.
You can detect if a service is started, stopped or exists by using a "Detect Service" predefined custom action. This custom action can be added at any point of the installation. If you want it to run at the beginning of the install process you can schedule it under "InstallUISequence" -> "Begin". It should also be dragged over "InstallExecuteSequence" -> "Begin" to make sure that it runs even if there is no UI.
Since it uses installer properties, this custom action can only run
as Immediate.
After adding the custom action, in its Custom Action Properties page, the Action Data field should be set to the name of the service you want to detect. When the custom action runs, it will set the AI_SERVICE_STATE property to one of these values:
- Started - the service is installed and it is started
- Stopped - the service is installed, but it is stopped
- Not Found - the service is not installed
The AI_SERVICE_STATE property can be used as a Custom Launch Condition in
order to stop the installation based on the service state.