2009-06-16 56 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