Windows服务不会停止,也不会在卸载时删除(Wix)

时间:2011-07-19 18:44:58

标签: windows-services wix wix3

我在stackoverflow上看到了一些与此相关的相关问题,但它们似乎都没有解决我正在观察的特定行为。

我在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 stop”时,我执行看到干净运行的服务关闭代码。)

以下是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.

2 个答案:

答案 0 :(得分:6)

哦,亲爱的,虽然在厕所里我有一个脑电波,我想我毕竟已经修好了 - 抱歉这个帖子!我想我会解释是什么解决了它,以防任何其他初学者跟我一样的Wix书遇到同样的问题。

基本上,我更改了组件上的Guid,重新安装,卸载,这一切都再次起作用。 (我认为改变Guids可能不是最佳做法,但这对我有用。)

详细说来,我认为我的安装程序实际上没有任何问题 - 问题出在我用来测试安装的PC上。我第一次尝试安装这个Windows服务是在没有ServiceControl元素的情况下完成的,只是ServiceInstall元素。然后我测试了安装,它工作,但显然,该服务并没有在卸载时删除自己。然后,我使用Services.msc手动停止并从我的PC上卸载了该服务。

然后我阅读了本书的下一部分,意识到我还需要一个ServiceControl元素,创建它并重新尝试安装程序 - 但我使用的是同一个Guid。卸载仍然无法正常工作,我认为我在安装程序中做错了,因此上面的帖子。

我猜测发生的事情是,之前的安装,使用相同的Guid但没有ServiceControl元素,导致我的PC以某种方式损坏并阻止新的卸载程序正常完成。

让我成为一个教训 - 永远不要在自己的电脑上测试安装程序!其中一条规则我完全理解并乐于忽视,直到它咬我:)

答案 1 :(得分:0)

检查详细日志文件并确保正在更改组件。可能是功能关闭或组件/条件导致跳过组件。

相关问题