如何在使用WiX Toolset(MSI安装程序)卸载期间停止服务?

时间:2015-10-14 03:43:38

标签: java wix windows-installer

我正在使用WiX Toolset来创建MSI安装程序。这将安装一个Java应用程序,该应用程序具有作为服务安装的本机包装器。

我已经安装好了,但是当我尝试卸载它时,Restart Manager会检测正在使用的文件并显示一个对话框,说明需要重新启动。

Windows服务运行本机包装器bin\wrapper-windows-x86-64.exe。其组件配置为:

    <DirectoryRef Id="bin97543xxxx">
        <Component Guid="cb21cd16-4bb9-4e57-a13c-4d064f01cd43" Id="bin_wrapper_windows_x86_64_exe189026768">
            <File KeyPath="yes" Source="bin\wrapper-windows-x86-64.exe" DiskId="1" Name="wrapper-windows-x86-64.exe" Id="fl_bin_wrapper_windows_x86_64_exe189026768"/>
            <RemoveFile Name="wrapper.log" On="uninstall" Id="rm_fl_bin_wrapper_log123456789"/>
            <ServiceInstall Name="Test App" Description="Test App" Arguments="-s &quot;..\conf\wrapper.conf&quot; wrapper.console.flush=true" Type="ownProcess" Vital="yes" Start="auto" Account="LocalSystem" ErrorControl="ignore" Interactive="no"/>
            <ServiceControl Id="StartService" Name="Test App" Start="install" Stop="both" Remove="uninstall" Wait="yes"/>
        </Component>
    </DirectoryRef>

此本机包装器将使用其他一些JAR和本机DLL启动JVM java.exe。这些JAR和DLL被定义为单独的组件,例如:

    <DirectoryRef Id="bin_wrapper_lib172428748">
        <Component Guid="91ea3118-769e-4100-80a2-f09a586500a5" Id="bin_wrapper_lib_wrapper_jar565349582">
            <File Source="bin\wrapper\lib\wrapper.jar" DiskId="1" Name="wrapper.jar" Id="fl_bin_wrapper_lib_wrapper_jar565349582"/>
        </Component>
    </DirectoryRef>

当我尝试卸载程序时,它会检测java.exe正在使用的文件,即使服务停止时它也会停止JVM。我在尝试卸载之前通过手动停止服务来验证这一点。另外要注意的是,如果我继续,那么所有文件都会被成功删除,只有Windows服务仍然存在(但标记为已删除)。 MSI日志显示:

Action start 15:48:40: InstallValidate.
... 
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Detected that application with id 3636, friendly name 'java.exe', of type RmCritical and status 1 holds file[s] in use.
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
...
MSI (s) (AC:68) [15:48:59:078]: RESTART MANAGER: The user chose to go on with the installation, although a reboot will be required.
...
The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.

我在SO和WiX Toolset用户邮件列表上看到了一些类似的问题,但没有什么真正有用。很多人都试图使用自定义操作,并被告知使用我已经使用的ServiceControl。

我也看到有人提到使用逻辑中的&#34;文件&#34;我假设是Restart Manager正在做的事情。有人建议使用ServiceControl元素将相关文件添加到组件中,但这似乎并不恰到好处(或者至少我不知道如何操作并仍然遵循分离组件的最佳实践)。

有人能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:1)

可能是相关帖子 - WiX: Avoid showing files-in-use dialog and just prompt for reboot at end of install

设置MSIRESTARTMANAGERCONTROL =禁用。如果这不起作用,请从MSI中删除FileInUse对话框;)

相关问题