Wix 在卸载/升级时停止服务:防止“重新启动弹出窗口";(文件使用情况) [英] Wix stop service on uninstall/upgrade: prevent "restart popup" (file-in-use situation)

查看:42
本文介绍了Wix 在卸载/升级时停止服务:防止“重新启动弹出窗口";(文件使用情况)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是,在卸载(或升级)重启管理器时抱怨文件处于使用状态,因此强制重启:

I've got the issue, that when uninstalling (or upgrading) the Restart Manager is complaining about a file in use situation, and so is forcing a reboot:

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 子进程:

The service that RESTART MANAGER is complainig about, is a java-based service. The service (here called myservice.exe) is recursively starting java child processes:

  myservice.exe --run
  ↳ javaw.exe --someArguments
     ↳ someother.exe --someArguments
       ↳ javaw.exe --someMoreArguments

  myservice.exe --run
   ↳ javaw.exe --someArguments
      ↳ someother.exe --someArguments
         ↳ javaw.exe --someMoreArguments

服务定义的 wix 片段:

The wix snippet for the service definition:

<DirectoryRef Id="BINDIR">
        <Component Id="myservice.exe" Guid="PUT-GUID-HERE">
            <File Id="myservice.exe" KeyPath="yes" Vital="yes"
                  Source="SourceDir\bin\myservice.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* 表中的条目对我来说似乎很好.

    The entries in the Service* Tables seems good for me so far.

    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
    


    所以,分解一切:似乎重新启动管理器没有识别,java 进程是子进程,将被 StopServices 操作停止.


    So, to break down everything: It seems that the Restart Manager is not recognizing, that the java processes are child processes and will be stopped by the StopServices action.

    我在这里发现了一些类似的问题:https://www.mail-archive.com/wix-users@lists.sourceforge.net/msg57924.html
    Wix 安装程序问题:为什么 RestartManager 标记服务作为 RMCritical 而不是 RMService

    I found some kind of similar problems here: 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

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

    Thanks in advance for any help to solve this issue!

    推荐答案

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

    You have a couple of options to resolve this issue:

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

    -Disable "Restart Manager" by making use of MSIRESTARTMANAGERCONTROL= "Disable" in the property table. This would kick in the legacy "FilesInUse" dialog box. In your case, The FilesinUse dialog might also not be displayed (since services do not have a window associated with them) The "FilesinUse" dialog box does not list processes which do not have a window associated with them. So, in your case, disabling the Restart Manager, might not display any dialogs(neither FilesInUse nor RestartManager).

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

    However, this would also mean that a reboot might be required, not necessarily because of your services but due to some other process which might be holding your files in use. If you think that there could be no other process other than your own services holding files, then go ahead and follow this approach . If you think that there could be other processes, other than your services holding files, then having "Restart Manager" enabled is ideal. Not having "Restart Manager" will either result in one of the things:

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

    -Display the Legacy FilesInUse dialog asking you to shut down the processes listed in the dialog. This might result in you having to shut down these processes via a custom action.

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

    Both the "RestartManager" and "FilesInUse" dialogs are displayed by the "InstallValidate" standard action. If you want to suppress both of these dialogs, then ensure that your custom action is scheduled before "InstallValidate" standard action. There is a catch here. Scheduling such a custom action before InstallValidate would have to be an immediate mode custom action(You cannot have deferred mode custom actions before "IntsallFinalize"). So , in cases where you are not running as an administrator(such as in UAC enabled scenarios), you might not have the necessary privileges to shut down applications. So , a restart might be required.

    -您还可以使用 WiX 实用程序扩展 CloseApplication() 函数关闭应用程序.评估您的方案并做适合您的事情.

    -You can also shut down applications using the using the WiX util extensions CloseApplication() function. Evaluate your scenario and do what is right for you.

    这篇关于Wix 在卸载/升级时停止服务:防止“重新启动弹出窗口";(文件使用情况)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆