使用Restart Manager时,如果我添加当前在命令提示符窗口中作为当前工作目录打开的RmRegisterResources路径, RmGetList不会返回它,而是返回有关其他锁定文件的信息(例如,加载的可执行文件) WinDBG)。
为什么会这样?
如果我尝试删除此文件夹,我会收到一个error 32: ERROR_SHARING_VIOLATION,这就是为什么我使用重新启动管理器来识别阻止我删除文件和文件夹的进程。
我有启动重新启动管理器会话的代码,然后使用一些文件调用RmRegisterResources ,当它调用RmGetList时,返回 ERROR_ACCESS_DENIED (5)...但是如果我添加睡眠 50 毫秒,然后重试...它可以工作... 怎么会?任何想法?除了 sleep 之外还有其他方法可以成功调用 RmGetList.txt 吗?
我遇到的问题是,在卸载(或升级)时,重新启动管理器抱怨某个文件正在使用中,因此强制重新启动:
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.
Run Code Online (Sandbox Code Playgroud)
RESTART MANAGER抱怨的服务是基于Java的服务。服务(此处称为myservice.exe)以递归方式启动java子进程:
myservice.exe-
运行
↳javaw.exe --someArguments↳someother.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="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"/> …Run Code Online (Sandbox Code Playgroud) 我遇到了一个与Restart Manager API有关的奇怪问题:RmGetlist().为了模拟文件锁定方案,我正在使用以下第三方文件锁定实用程序:
Ez文件柜 - http://www.xoslab.com/efl.html -
文件柜 http://www.jensscheffler.de/filelocker
这里的奇怪问题是,这两个实用程序都锁定了某个文件,但是,RMGetList()失败,带有第一个文件锁定实用程序(Ez文件锁定)的Access拒绝错误(5),而它与第二个文件锁定实用程序一起使用.
这可能有什么问题?为什么RmGetList()会因一个文件锁定实用程序失败而与另一个一起工作?
以下是正在使用的代码:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.IO;
using System.Windows.Forms;
namespace RMSession
{
class Program
{
public static void GetProcessesUsingFiles(string[] filePaths)
{
uint sessionHandle;
int error = NativeMethods.RmStartSession(out sessionHandle, 0, Guid.NewGuid().ToString("N"));
if (error == 0)
{
try
{
error = NativeMethods.RmRegisterResources(sessionHandle, (uint)filePaths.Length, filePaths, 0, null, 0, null);
if (error == 0)
{
RM_PROCESS_INFO[] processInfo = null;
uint pnProcInfoNeeded = 0, pnProcInfo = 0, …Run Code Online (Sandbox Code Playgroud) 当有文件的更新补丁必须用现有文件替换时,如果其中一个文件正在被任何进程使用,则会弹出一个正在使用的文件对话框。我想避免那个对话框并使该文件排队等待安装,以便在系统重新启动时安装它。我已经读到在重新启动时排队更新文件是 Windows 安装程序的内置功能。有人可以建议我删除那个 FileInUse 对话框的方法。我尝试将“MsiRMFilesInUse”属性设置为“0”,但没有奏效。
卸载我的应用程序时,如果它正在运行,它会尝试停止它:
遗憾的是,自动关闭并不真正起作用,它显示以下错误:
我的应用程序消失了,窗户,托盘栏图标,它们都消失了.但我仍然可以在流程列表中看到它们.
我猜测Windows向应用程序发送信号以便正常退出并且UI会这样做,但是有一些挥之不去的线程阻止进程终止.
Windows Installer如何在卸载期间关闭应用程序?
一旦我知道这一点,我想在调试我的应用程序时模拟它,看看发生了什么.这是一个合理的计划吗?
windows windows-installer restartmanager windows-restart-manager