0

I’m using an MSI installer (built with the WiX ServiceInstall element) to deploy a Windows Service. The service installs correctly, and I start it manually in the Services.

When uninstalling the MSI through “Add or Remove Programs,” I encounter two scenarios:

1: Service not Running: If the service is not running, the MSI uninstalls cleanly (this works as expected).

2: Service running: If the service is running, the MSI still stops and service is removed automatically.

I want when the service is running it should show below default windows message box.

Image of default windows message box

Code for the Service Installation:

new ServiceInstaller
{
    Name = "IP.ServiceInstaller.exe",
    DisplayName = "[IASSERVICENAME]",
    Description = "This is a Service",
    StartOn = null, //set it to null if you don't want service to start as during deployment
    StopOn = SvcEvent.InstallUninstall,
    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]"
}),

What are the changes should be for the given code?

3
  • I don't think is possible because is a service and not an application. What u presented on top is the normal flow of installing/uninstalling a service. Commented Apr 24 at 7:22
  • Can’t we change the StopOn or RemoveOn properties to prevent the service from being removed automatically and instead show the above Windows “service in use” message? Commented Apr 24 at 7:28
  • While this is not a direct answer, it's not specific to WiX, you can control the service and not remove it during an uninstall using the Windows installer ServiceInstall table, learn.microsoft.com/en-us/windows/win32/msi/…. Without looking myself I'm sure there is a direct way to control this with WiX that just builds Windows installer MSIs. Commented Apr 28 at 11:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.