1
votes

I have a installation package made using the Wix toolset, that includes a service created with Embarcadero's C++ Builder. ECB has a different syntax to register/unregister services under Windows if compared to Visual Studio C++/C#, I was not able to register the service through the regular Wix element <ServiceInstall>, the installer freezes during the service registration/unregistration. I found a solution through the Wix Custom Actions. I created the following actions:

    <CustomAction
        Id="LaunchApp_SrvInstall"
        Directory="INSTALLDIR"
        Impersonate="no"
        Execute="deferred"
        ExeCommand="&quot;[INSTALLDIR]ACService.exe&quot; /install /silent">
    </CustomAction>
    <CustomAction
        Id="LaunchApp_SrvUninstall"
        Directory="INSTALLDIR"
        Impersonate="no"
        Execute="deferred"
        ExeCommand="&quot;[INSTALLDIR]ACService.exe&quot; /uninstall /silent">
    </CustomAction>

    <InstallExecuteSequence>
        <Custom Action="LaunchApp_SrvInstall"   After="InstallFiles">NOT REMOVE</Custom>
        <Custom Action="LaunchApp_SrvUninstall" Before="RemoveFiles">REMOVE ~= "ALL"</Custom>
    </InstallExecuteSequence>

With the syntax above, during the package install, after the files are copied to the installation directory I have the service registered, and if I'm uninstalling the package the service is unregistered before the installed files are removed. In both cases it works perfectly. The problem I'm facing happens when I try to update the software to a newer version, I have the scenario where the software and the service are running and the user tries to install the new MSI package to update the entire solution. In that case, I have the following popup:

enter image description here

It seems that during the update process, the installer is trying to register the service twice, but I can't figure why. Does anyone here already faced such situation? Is there a way to configure the Custom Actions to work also during the package update?

1
Please test on a clean virtual - you could have "dirty state errors". I am not sure that binary needs anything special, you should try this sample project and inject your own binaries to see if that works: github.com/Robs79/… - the service start calls and SCM code must comply to some standards? - Stein Åsmul
Thank you guys. But all the given examples are in C#. I think WiX is the default install tool in Visual Studio; in that case there is no need to use Custom Actions to handle the service installation, because a service created with C# could use the <ServiceInstall> element directly. The problem I'm facing is due to the fact the service was created using C++ Builder, and it seems the <ServiceInstall> element does not have support for a C++ builder created service. - André Murta
Not sure that is true with the C++ builder. Service binaries should comply with SCM commands? (start, stop, pause, etc...). I am not sure. You should try to inject your C++ builder binaries in the samples above to verify. Did you try this? Using custom actions to install services is not a good approach, but possible. I have this old answer on various service installation approaches. - Stein Åsmul
It's puzzling, I adapted the sources at github.com/rstropek/Samples/tree/master/WiXSamples/… using a simple example service made with C++ Builder. I have the same behavior as before, the install freezes when trying to register the service. I can see the install folder created, the MSI contents are in there; using Task Manager I confirm the service executable is running, but is not yet registered as a service in Windows. At this point the installation freezes, I think I'll have to use a different MSI package generator. - André Murta

1 Answers

2
votes

After the useful tips given in the comments, everything worked when I correlated the properties Name and DisplayName of the Embarcadero's IDE with the tags Name and DisplayName of the WiX installer project source, also, it was necessary to define the Arguments tag in <ServiceInstall>

enter image description here enter image description here

That's it. Now I can handle my service using WiX. I'm quite confident the details above are also valid for the Delphi compiler.