2009-06-16 59 views
6

停止Windows服务当我卸载我的服务,我得到它说我必须在卸载前停止某某服务错误。这是不令人满意的 - 卸载程序应该自动停止它。维克斯:在卸载

我发现这个月以前博客或新闻组文章,得到它正常工作,但现在它已停止为我工作。我没有链接到帖子...也许别人知道它在哪里? :)我想我改变了一些微妙的东西,它停止工作。我发现Wix非常难以排除故障。

我使用下面包括获取财产X_ WIN_ SERVICE_ NAME(对不起,我不知道如何避免_逃逸这里)从注册表中。不要紧上安装,因为在这种情况下,我明确地与输入文件中设置它。这包括在我的wxs文件中的任何组件之前使用。

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

以下包括组件使用,以节省安装的注册表键值:

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

我检查我的系统安装后和注册表值正确地写在那里。我的组件中设置服务的部分看起来像:

  <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" /> 

任何想法?

回答

4

您确保X_WIN_SERVICE_NAME属性设置为上卸载正确的值。使用详细的日志文件来确保搜索正确设置值。一切都看起来不错(虽然我不知道为什么你把一切都在包含文件,而不是只用片段)。

+0

你是对的,它一定是微妙的,因为经过一些无关的改变后,它再次工作:S – evilfred 2009-07-03 23:21:00