在安装期间注销Windows服务(Wix)



我们的产品安装程序的旧版本使用Wix以外的东西在卸载时"忘记"注销已安装的服务。

如果我们运行当前的安装程序(使用Wix),当它想要安装服务时,它会弹出"拒绝访问"。

为了应对这种情况,我在安装服务的组件中添加了以下内容:

<RemoveRegistryKey Id="ServiceRegistrationRouter" Action="removeOnInstall" Key="SYSTEMCurrentControlSetservicesRouter" Root="HKLM"/>

"RemoveRegistryValues"(序列2600)的计划早于"InstallServices"(序列5800),因此应清除延迟注册表项。

这很有魅力,但我还是得到了"拒绝访问"。因此,即使注册表项不见了,Windows仍然保留着该服务。

我知道"sc删除"会解决问题,但如果可能的话,我想避免自定义操作。

这可能吗?

创建一个单独的Component并将其添加到所需的ComponentGroup。看起来是这样的:

<Component Id="C_RemoveOldServices" Guid="B7574124-A3A8-4535-A14E-616E5024CA7F" KeyPath="yes">
<ServiceControl Id="old_service1" Name="Service 1" Remove="install" Wait="no"/>
<ServiceControl Id="old_service2" Name="Service 2" Remove="install" Wait="no"/>
<ServiceControl Id="old_service3" Name="Service 3" Remove="install" Wait="no"/>
<ServiceControl Id="old_service4" Name="Service 4" Remove="install" Wait="no"/>
<Condition>![CDATA[NOT Installed]]</Condition>
</Component>

最新更新