Wix: stop Windows service when uninstalling

When I delete my service, I receive an error message stating that I must stop such and such a service before uninstalling. This is unsatisfactory - the uninstaller should automatically stop it.

I found a blog or news posting this month ago and made it work correctly, but now it stops working for me. And I don’t have a link to the message ... maybe someone else knows where it is? :) I think I changed some subtle things and it stopped working. I find Wix extremely difficult to fix.

I use the following include to retrieve the X_ WIN_ SERVICE_ NAME property (sorry I do not know how to avoid escaping here) from the registry. It does not matter during installation, because in this case I explicitly install it using the input file. This parameter is used before any components in my wxs file.

<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"> <?ifndef SetupXWinServiceRegistryProperties ?> <?define SetupXWinServiceRegistryProperties ?> <?define XWinServiceRegistryKey='Software\X\Y'?> <Property Id="X_WIN_SERVICE_NAME"> <RegistrySearch Id="XWinServiceNameSearch" Root="HKLM" Key="$(var.XWinServiceRegistryKey)" Name="ServiceName" Type="raw"/> </Property> <?endif?> </Include> 

The following component includes a component for storing registry values ​​during installation:

 <Include xmlns="http://schemas.microsoft.com/wix/2006/wi"> <?ifndef WriteXWinServiceRegistryProperties ?> <?define WriteXWinServiceRegistryProperties ?> <Component Id="CompWriteXWinServiceRegistryProps" Guid="some guid"> <!-- Write properties to the registry. Then they will be accessable during uninstall. --> <RegistryValue Root="HKLM" Key="$(var.XWinServiceRegistryKey)" Name="ServiceName" Type="string" Value="[X_WIN_SERVICE_NAME]" Action="write" /> </Component> <?endif?> </Include> 

I checked my system after installation, and the registry value is correctly written there. The part of my component where the service is configured looks like this:

  <ServiceInstall Id="ServiceInstallXWinService" Name="[X_WIN_SERVICE_NAME]" Start="auto" DisplayName="xxx" Description="yyy" Account="[X_WIN_SERVICE_USER]" Password="[X_WIN_SERVICE_PASSWORD]" Type="ownProcess" ErrorControl="normal" Vital="yes" /> <ServiceControl Id="ServiceInstallXWinService" Name="[X_WIN_SERVICE_NAME]" Stop="both" Remove="uninstall" Wait="yes" /> 

Any ideas?

+6
wix windows-services wix3
source share
1 answer

Are you sure that when you delete the property X_WIN_SERVICE_NAME is set to the correct value. Use the verbose log file to verify that the search matches the value correctly. Everything looks fine (although I don’t know why you put everything in Include files instead of using fragments).

+4
source share

All Articles