gpt4 book ai didi

wix - 微星 : How a Service is stopped on uninstall during InstallValidate - could that work anyway?

转载 作者:行者123 更新时间:2023-12-01 16:15:34 26 4
gpt4 key购买 nike

我想知道,如果服务被标记为 Remove="uninstall" Stop="uninstall",具体如何以及何时尝试停止它。在 WiX 项目文件中。

为什么我要问:
卸载时,重新启动管理器无法识别或正确处理该服务,从而导致“重新启动对话框”。

我将调试器附加到服务并意识到,它从未被尝试过停止 - 至少,不是通过注册的 ControlHandler。我在猜测,它将以与执行“sc stop servicename”相同的方式停止或通过服务对话框停止它。服务本身是用 C++ 编写的,控制处理程序由 RegisterServiceCtrlHandler 注册。这在两种概述的情况下都很正常。停止服务时调用处理程序。不是这样,如果它是通过 MSI 停止/卸载的。

顺便说一句,正如 jbudreau 在 Wix Installer Problem: Why does RestartManager mark Service as RMCritical and not RMService 中的回答所述如果服务作为 LocalSystem 运行,是否可以在 InstallValidate 部分停止服务?在 InstallValidate 中,卸载过程尚未提升。

对停止 LocalSystem 服务的过程在卸载时如何工作的一些解释会很棒!

提前致谢!

编辑:
这是我使用 ServiceInstall 和 ServiceControl 的服务定义:

        <DirectoryRef Id="BINDIR">
<!-- the service -->
<Component Id="myProgramsvc.exe" Guid="1f64c03f-26ea-47ba-985c-2a566afffffa">
<File Id="myProgramsvc.exe" KeyPath="yes" Vital="yes"
Source="SourceDir\bin\myProgramsvc.exe"/>
<ServiceInstall Id="MyProgramSvc" Type="ownProcess"
Vital="yes" Name="MyProgramSvc" DisplayName="Test MyProgram Service"
Description="Test MyProgram Service" Start="auto" Account=".\LocalSystem"
ErrorControl="normal" Interactive="no" Arguments="--run"/>
<ServiceControl Id="MyProgramSvc" Name="MyProgramSvc" Wait="yes" Remove="uninstall" Stop="uninstall" Start="install"/>
</Component>
</DirectoryRef>

以及进程层次结构,其中 RestartManager 提示 ----as.exe(PID:4312):
process hierarchy of the service
编辑 2: (id 9324 与截图不同,取自不同尝试的日志文件)
MSI (s) (BC:38) [16:46:14:141]: RESTART MANAGER: Detected that application with id 9324, friendly name '---as.exe', of type RmCritical and status 1 holds file[s] in use.
MSI (s) (BC:38) [16:46:14:141]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.

编辑 3:
日志文件: uninstall.log - 日志文件太大,无法在此处发布(30000 个字符限制)。

最佳答案

InstallValidate 不会停止服务 - 这是由 StopServices 操作完成的。 InstallValidate 试图找出正在使用的文件(使用重新启动管理器)并显示正在使用的文件对话框。就服务而言,它会忽略 ServiceControl 表中具有“卸载时停止”设置的服务正在使用的任何文件。如果您想确保服务完全停止,请使用 wait="yes"。这是一个标准的停止服务控制处理程序调用。

如果该服务触发了一堆仍在运行的进程,那么这只是一个普通的文件使用问题,与服务无关。这些进程需要关闭调用(来自服务?)或者它们应该与重启管理器集成,这种事情:http://www.codeproject.com/Articles/772868/Restart-Manager-Support-For-Windows-Application

如果进程响应 Windows 消息,WiX util CloseApplication 应将其关闭。

我要指出的是,您的 WiX 中可能只是存在一个错误,其中 ServiceControl 中命名的服务不正确。由于您可以控制任何服务(不仅仅是您正在安装/卸载的服务),因此无需检查名称是否与您的服务或任何其他服务相对应。如果您从未看到停止调用服务控制,这是最简单的解释。

关于wix - 微星 : How a Service is stopped on uninstall during InstallValidate - could that work anyway?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36887205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com