问题
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:
- I install my bits into the Application Folder
- I launch a custom action to Install the 3rd party app via FooSetup.exe
- I launch another custom action to license the third party app via FooLicense.exe, installed during step 2.
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.
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)
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.
回答1:
I guess Process.WaitForExit()
is what you want. http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx
来源:https://stackoverflow.com/questions/12899138/monitoring-process-exits-in-a-custom-action