2011-07-19 83 views
5

我已經看到了與此相關的一些與stackoverflow有關的問題,但他們都沒有解決我觀察到的特定行爲。Windows服務不會停止,也不會在卸載時被刪除(Wix)

我在Wix 3.0 .wxs文件中定義瞭如下的Windows服務。

<Component Id='Service' Guid='3c658a54-b236-11e0-bbf6-039615e482ae' > 

    <File Id='ServiceEXE' Name='m_agent_service.exe' 
      Vital='yes' Source='..\m_agent_service.exe' 
      KeyPath='yes' /> 

    <ServiceInstall Id='MerakiServiceInstall' 
     Vital='yes' 
     Name='MerakiPCCAgent' DisplayName='Meraki Client Insight Agent $(env.VERSION)' Description="Meraki Client Insight Monitoring and Management Service" 
     Type='ownProcess' Interactive='no' Start='auto' ErrorControl='normal'> 
    </ServiceInstall> 

    <ServiceControl Id='MerakiServiceControl' 
     Name='MerakiPCCAgent' 
     Start='install' Stop='both' Remove='uninstall' 
     Wait='yes' /> 
</Component> 

當我安裝.MSI時,服務已安裝並正在運行。大。

當我然後卸載(或者通過運行MSIEXEC/x或使用添加/刪除從控制面板軟件)時,服務繼續運行和不會被刪除。事實上,服務本身的日誌告訴我沒有任何服務關閉代碼已被調用。 (當我使用「SC停」,例如,我看到服務關閉運行的代碼乾淨。)

下面是從MSIEXEC/X卸載記錄一些突出的部分:

MSI (s) (14:04) [11:33:54:692]: 1 application(s) had been reported to have files 
in use. 
Info 1603. The file C:\Program Files\Meraki\PCC Agent 1.0.67\m_agent_service.exe 
is being held in use by the following process: Name: m_agent_service, Id: 3120, 
Window Title: '(not determined yet)'. Close that application and retry. 
MSI (c) (40:78) [11:33:54:692]: File In Use: -m_agent_service- Window could not 
be found. Process ID: 3120 
MSI (c) (40:78) [11:33:54:692]: No window with title could be found for FilesInUse 

[...] 

Action start 11:33:57: UnpublishFeatures. 
MSI (s) (14:04) [11:33:57:379]: Doing action: StopServices 
MSI (s) (14:04) [11:33:57:379]: Note: 1: 2205 2: 3: ActionText 
Action ended 11:33:57: UnpublishFeatures. Return value 1. 
Action start 11:33:57: StopServices. 
MSI (s) (14:04) [11:33:57:379]: Doing action: DeleteServices 
MSI (s) (14:04) [11:33:57:379]: Note: 1: 2205 2: 3: ActionText 
Action ended 11:33:57: StopServices. Return value 1. 
Action start 11:33:57: DeleteServices. 
MSI (s) (14:04) [11:33:57:379]: Doing action: RemoveFiles 

[...] 

MSI (s) (14:04) [11:33:57:645]: Product: Meraki Client Insight Agent -- Removal 
completed successfully. 

MSI (s) (14:04) [11:33:57:645]: Windows Installer removed the product. Product N 
ame: Meraki Client Insight Agent. Product Version: 1.0.67. Product Language: 103 
3. Removal success or error status: 0. 
+0

您正在創建的服務取決於一些其他文件或程序集?如果是這樣,那麼你需要獲得服務的進程ID,然後終止進程。那麼你可以卸載服務 –

回答

0

檢查詳細的日誌文件並確保組件正在更改。可能關閉了功能,或者組件/條件導致組件被跳過。

5

哦,親愛的,雖然在廁所我有一個腦波,我想我已經修復了它 - 畢竟對不起!我想我應該解釋一下,但是如果其他初學者跟我一樣在Wix書上遇到同樣的問題,我會解釋它。

基本上,我改變了我的組件Guid,重新安裝,卸載,它一切工作。 (我接受改變的Guids可能不是最佳做法,但這對我很有用。)

詳細說明,我認爲實際上我的安裝程序沒有任何問題 - 問題出在我用的PC上測試安裝。我第一次嘗試安裝這個Windows服務時,沒有使用ServiceControl元素,只是ServiceInstall元素。然後,我測試了安裝,並且它工作正常,但顯然,該服務並未在卸載時自行移除。然後我使用Services.msc手動停止並卸載了我的PC上的服務。

然後我讀了我的書的下一部分,意識到我還需要一個ServiceControl元素,創建它並重新嘗試安裝程序 - 但我使用的是同一個Guid。卸載仍然無法正常工作,並且我認爲我在安裝程序中做了錯誤的處理,因此上面的文章。

我猜測發生的事情是,前一次安裝,使用相同的Guid但沒有ServiceControl元素,導致我的電腦受到損壞,並阻止新的卸載程序正常完成。

讓我成爲一個教訓 - 切勿在您自己的PC上測試您的安裝程序!其中一條規則我完全理解並樂於忽略,直到它咬我:)

+0

正是我現在正在經歷的。 10x :) – mynkow

+0

同樣在這裏,如果你有這個問題,試試這個! – joepetrakovich