views:

708

answers:

1

Hi,

When I uninstall my service I get the error where it says I have to stop such and such service before uninstalling. This is unsatisfactory - the uninstaller should automatically stop it.

I found a blog or newsgroup posting on this months ago and got it to work properly, but now it has stopped working for me. And I don't have a link to the post... maybe someone else know where it is? :) I guess I changed some subtle thing and it stopped working. I find Wix extremely difficult to troubleshoot.

I am using the following include to fetch the property X_ WIN_ SERVICE_ NAME (sorry I don't know how to avoid _ escaping here) from the registry. It doesn't matter on install because in that case I explicitly set it with an input file. This include is used before any components in my wxs file.

<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;

<?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 include component is used to save the registry value on install:

<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;

<?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 have checked my system after install and the registry value is properly written there. The part in my component where the service is setup looks like:

          <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?

+1  A: 

Are you sure that the X_WIN_SERVICE_NAME property is set to the correct value on uninstall. Use a verbose log file to make sure that the search is setting the value correctly. Everything looks fine (although I don't know why you put everything in Include files instead of just using Fragments).

Rob Mensching
you're right, it must have been something subtle because after some unrelated changes it's working again :S
evilfred