Service from another Instance Not Removed During Uninstallation
Hello @oleg-shilo,
I'm installing an application that includes a Windows service. I have multiple instances of this application installed. Each instance installs its own service, for example:
Default instance installs: TestService Second instance installs: TestService_SecondInstance
Code for the Windows Service:
new ServiceInstaller
{
Name = "TestService_[INSTANCEID]",
DisplayName = "[SERVICENAME]",
Description = "test",
StartOn = null, //set it to null if you don't want service to start as during deployment
StopOn = SvcEvent.Install,
RemoveOn = SvcEvent.Uninstall_Wait,
DelayedAutoStart = false,
ServiceSid = ServiceSid.none,
FirstFailureActionType = FailureActionType.restart,
SecondFailureActionType = FailureActionType.restart,
ThirdFailureActionType = FailureActionType.runCommand,
RestartServiceDelayInSeconds = 30,
ResetPeriodInDays = 1,
PreShutdownDelay = 1000 * 60 * 3,
Account = "[USERNAME]",
Password = "[PASSWORD]"
}),
Problem:
When I uninstall the default instance using Windows Add or Remove Programs (ARP), its corresponding service (TestService) is correctly removed.
However, when I uninstall the second instance, the associated service (TestService_SecondInstance) does not get uninstalled.
Any solution that will remove services from other instances during uninstall?
morning, i dont think it possible in your way. both MSI´s doesnt know each other if both of your msi with windows services are in separate msi. Solution is BA Installer.
preudo code , not tested
public override void Run()
{
Engine.Detect();
if (Command.Action == LaunchAction.Uninstall)
{
Engine.Log(LogLevel.Verbose, "Starting uninstall of all chained MSIs...");
Engine.Plan(LaunchAction.Uninstall);
Engine.ApplyComplete += (s, e) => Engine.Quit(0);
}
else
{
Engine.Plan(LaunchAction.Install);
Engine.ApplyComplete += (s, e) => Engine.Quit(0);
}
Engine.Apply();
}
Each MsiPackage will receive the uninstall signal and remove its own service only if its ServiceInstaller is correctly configured (i.e., RemoveOn = SvcEvent.Uninstall).
When RemoveOn = SvcEvent.Uninstall, the service gets removed immediately—even if it's still running. This behavior wasn't what I wanted, and I had discussed it earlier in issue #1781.
I haven't tried your suggested solution yet. Instead, I created a separate custom action and added a check, which worked for me