简体   繁体   English

监视自定义操作中的流程退出

[英]Monitoring Process Exits in a Custom Action

All – 全部–

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. I install my bits into the Application Folder 我将自己的位安装到应用程序文件夹中
  2. I launch a custom action to Install the 3rd party app via FooSetup.exe 我启动自定义操作,以通过FooSetup.exe安装第三方应用程序
  3. I launch another custom action to license the third party app via FooLicense.exe, installed during step 2. 我启动了另一个自定义操作,以通过步骤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);
}

It works fine – however, I can't begin “phase 3” (license the third party app) until fooSetup.exe actually completes. 它可以正常工作-但是,直到fooSetup.exe实际上完成后,我才能开始“阶段3”(许可第三方应用程序)。

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? 我猜我将不得不在myProcess上设置一个事件处理程序,以监视fooSetup.exe的退出? (I've validated that FooSetup.exe indeed exits post-completion while in silent mode) (我已经验证了FooSetup.exe在静默模式下确实会退出完成后的操作)

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. 我是一名商业智能专家,还是一名C#骑师,因此,如果您向我推销任何示例/指针,将不胜感激。

I guess Process.WaitForExit() is what you want. 我猜想Process.WaitForExit()是您想要的。 http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx http://msdn.microsoft.com/zh-CN/library/fb4aw7b8.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM