监视自定义操作中的流程退出 [英] Monitoring Process Exits in a Custom Action

查看:92
本文介绍了监视自定义操作中的流程退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部–

我需要通过自定义操作以静默方式执行多项任务。从本质上讲,我需要先放置自己的位,然后才能安装和许可第三方应用程序:

I need to carry out several tasks silently via Custom Actions. Essentially, I need to install and license a 3rd party application after I've laid down my own bits:


  1. 我将位安装到应用程序文件夹

  2. 我启动自定义操作以通过FooSetup.exe安装第三方应用程序

  3. 我启动另一个自定义操作以许可第三方应用程序通过在第2步中安装的FooLicense.exe。

在安装程序的提交阶段,我触发此代码以启动静默安装第三方应用程序的地址:

During the Commit phase of the installer, I fire this code to launch the silent setup of the 3rd party application:

[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Commit(IDictionary savedState)
{
  base.Commit(savedState);

  ProcessStartInfo startInfo = new ProcessStartInfo();
  startInfo.Arguments = "/verysilent";
  startInfo.FileName = Context.Parameters["TARGETDIR"].ToString() + "fooSetup.exe";
  Process myProcess = System.Diagnostics.Process.Start(startInfo);
}

工作正常–但是,我无法开始第3阶段(许可第三方应用程序),直到fooSetup.exe实际完成为止。

It works fine – however, I can’t begin "phase 3" (license the third party app) until fooSetup.exe actually completes.

解决这种情况的最佳实践是什么?我猜想我将不得不在myProcess上设置一个事件处理程序来监视fooSetup.exe的退出? (我已经验证了FooSetup.exe在静默模式下确实会退出完成后的操作)

What is the best practice to approach this scenario? I’m guessing I’m going to have to setup an Event Handler on myProcess to watch for the exit of fooSetup.exe? (I've validated that FooSetup.exe indeed exits post-completion while in silent mode)

还有任何示例吗?
我是一名商业智能专家,而不是C#骑师,因此,请您向我推荐的任何示例/指针都将受到赞赏。

Any examples out there? I’m a Business Intelligence guy vs. a C# jockey, so any samples/pointers you push me towards would be appreciated.

推荐答案

我想 Process.WaitForExit()是您想要的。 http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx

这篇关于监视自定义操作中的流程退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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