在某些时候,我需要赶上msiexec
流程启动及其结束事件。我的代码正在使用通常的用户权限。 Windows将以系统权限启动msiexec
进程,因此我不能执行Refresh()
并检查该进程的HasExited
属性。为什么Process.GetProcessesByName(“msiexec”)显示错误的结果?
while (true) {
Process[] msi = Process
.GetProcessesByName("msiexec");
if (msi.Length > 0) break;
}
// The `msiexec` is launched. Now to wait its finishing...
while (true) {
Process[] msi = Process
.GetProcessesByName("msiexec");
if (msi.Length == 0) break; // Here is `false` always!
}
// Components was installed.
但第二while
循环总是显示msi.Length == 1
甚至msiexec
后,将完成。为什么会发生?我该如何解决它?
所以,你在所有的系统程序的外观和有* NO * MSIEXEC进程中运行的下降?你对此100%确定?如果是这样,那么你刚刚在.NET中发现了一个错误。 – aquinas
取而代之的是使用循环,你不能在找到过程之后调用'WaitForExit()'方法吗? –
@ChrisDunaway,不,它不起作用。我在创建这个主题之前尝试了它。问题是'msiexec'可以处理系统权限。 –