加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

卸载/升级时的Wix停止服务:防止“重启弹出”(文件在用情况)

发布时间:2020-12-13 20:38:39 所属栏目:Windows 来源:网络整理
导读:我遇到了这个问题,在卸载(或升级)时,重启管理器抱怨文件处于使用状态,因此强制重启: RESTART MANAGER: Detected that application with id 7000,friendly name 'javaw.exe',of type RmCritical and status 1 holds file[s] in use.RESTART MANAGER: Did det
我遇到了这个问题,在卸载(或升级)时,重启管理器抱怨文件处于使用状态,因此强制重启:
RESTART MANAGER: Detected that application with id 7000,friendly name 'javaw.exe',of type RmCritical and status 1 holds file[s] in use.
RESTART MANAGER: Did detect that a critical application holds file[s] in use,so a reboot will be necessary.

RESTART MANAGER抱怨的服务是基于java的服务.该服务(此处称为myservice.exe)以递归方式启动java子进程:

myservice.exe – 运行
?javaw.exe–someArguments
?tomeother.exe–someArguments
?javaw.exe–someMoreArguments

服务定义的wix片段:

<DirectoryRef Id="BINDIR">
        <Component Id="myservice.exe" Guid="PUT-GUID-HERE">
            <File Id="myservice.exe" KeyPath="yes" Vital="yes"
                  Source="SourceDirbinmyservice.exe"/>
            <ServiceInstall Id="MyService" Type="ownProcess"
                            Vital="yes" Name="MyService" DisplayName="My Service"
                            Description="My Service" Start="auto" Account=".LocalSystem"
                            ErrorControl="normal" Interactive="no" Arguments="--run"/>
            <ServiceControl Id="MyService" Name="MyService" Wait="yes" Remove="uninstall" Stop="uninstall" Start="install"/>
        </Component>
</DirectoryRef>

现在,有趣的部分:

>安装时可以启动该服务

卸载时:

>如果没有运行,它将被删除
>如果正在运行,只是同意重新启动

>它确实在大约2-3秒内停止(我想通过StopServices动作)
>并成功删除(通过RemoveServices操作)

到目前为止,Service * Tables中的条目似乎对我有用.

ServiceControl-Table:
ServiceControl  Name       Event  Arguments  Wait  Component_
MyService       MyService  161               1     myservice.exe

ServiceInstall-Table:
ServiceInstall  Name       DisplayName  ServiceType StartType ErrorControl LoadOrderGroup Dependencies StartName Password Arguments Component_     Description
MyService       MyService  My Service   16          2         32769        .LocalSystem                                  --run     myservice.exe  My Service

所以,打破一切:
似乎Restart Manager无法识别java进程是子进程,并且将由Stop??Services操作停止.

我在这里发现了一些类似的问题:
https://www.mail-archive.com/wix-users@lists.sourceforge.net/msg57924.html
Wix Installer Problem: Why does RestartManager mark Service as RMCritical and not RMService

在此先感谢您解决此问题的任何帮助!

您有几个选项可以解决此问题:

-Disable“Restart Manager”,在属性表中使用MSIRESTARTMANAGERCONTROL =“Disable”.这将启动传统的“FilesInUse”对话框.
在您的情况下,也可能不会显示FilesinUse对话框(因为服务没有与之关联的窗口)
“FilesinUse”对话框不会列出没有与之关联的窗口的进程.因此,在您的情况下,禁用重新启动管理器可能不会显示任何对话框(FilesInUse和RestartManager).

但是,这也意味着可能需要重新启动,不一定是因为您的服务,而是由于某些其他进程可能正在使用您的文件.如果您认为除了您自己的服务保留文件之外不会有其他进程,那么请继续并遵循此方法.如果您认为除了服务保存文件之外可能还有其他进程,那么启用“重新启动管理器”是理想的选择.没有“重新启动管理器”将导致以下任何一件事:

– 显示Legacy FilesInUse对话框,要求您关闭对话框中列出的进程.这可能导致您必须通过自定义操作关闭这些进程.

“InstallManager”和“FilesInUse”对话框都由“InstallValidate”标准操作显示.如果要禁止这两个对话框,请确保在“InstallValidate”标准操作之前安排自定义操作.这里有一个问题.在InstallValidate之前安排这样的自定义操作必须是立即模式自定义操作(在“IntsallFinalize”之前不能有延迟模式自定义操作).因此,如果您没有以管理员身份运行(例如在启用UAC的情况下),您可能没有必要的权限来关闭应用程序.因此,可能需要重新启动.

– 您还可以使用WiX util扩展CloseApplication()函数关闭应用程序.评估您的场景并做适合您的事情.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读