Windows services Windows服务在卸载时不停止且未删除(Wix)

Windows services Windows服务在卸载时不停止且未删除(Wix),windows-services,wix,wix3,Windows Services,Wix,Wix3,我在stackoverflow上看到了一些与此相关的问题,但它们似乎都没有解决我所观察到的具体行为 我在WIX3.0.wxs文件中定义了一个Windows服务,如下所示 <Component Id='Service' Guid='3c658a54-b236-11e0-bbf6-039615e482ae' > <File Id='ServiceEXE' Name='m_agent_service.exe' Vital='yes' Source='..

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

我在WIX3.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>

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

哦,天哪,在上厕所时,我有一个脑波,我想我毕竟已经自己修复了它-抱歉!我想我应该解释一下是什么解决了这个问题,以防其他跟我一样学习Wix的初学者遇到同样的问题

基本上,我更改了我的组件上的Guid,重新安装,卸载,然后一切都恢复正常。(我认为更改guid可能不是最佳实践,但这对我来说很有效。)

更详细地说,我认为我的安装程序实际上根本没有问题——问题出在我用来测试安装的电脑上。我第一次尝试安装此windows服务时没有使用ServiceControl元素,只有ServiceInstall元素。然后我对安装进行了测试,它成功了,但很明显,卸载时服务并没有自动删除。然后,我使用Services.msc手动停止并卸载了PC上的服务

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

我猜之前的安装使用了相同的Guid,但没有ServiceControl元素,导致我的电脑以某种方式损坏,并阻止新的卸载程序正常完成


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

您正在创建的服务是否依赖于其他文件或程序集?如果是这样,那么您需要获取服务的进程id,然后终止该进程。然后您可以在此处卸载serviceSame,如果您遇到此问题,请尝试此项!
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.