Start an Independent Process

Feb 8 2008 3:08 PM

I have two executables, let's call them A and B.  As A is terminating, I want it to launch B and then terminate.  B is actually an installer, and one of the things it will do is replace the file A.exe, so A really cannot be open (running) when B does it's work.

When I use System.Diagnostics.Process.Start, B appears to be running somehow within the context of A, because if I don't make A wait for B to finish as in:

Process pr = new Process();
pr.StartInfo.FileName = installerPath;
pr.Start();
//pr.WaitForExit();

B dies (rather ungracefully) as A terminates.  If I make A wait for B to finish (uncommenting out the WaitForExit), then B cannot update A's file since A is still running.

What I really want is a way for A to start B in such a way that B is completely independent of A.  Then A could terminate and B could update A.exe.

Can anyone give me any idea how to accomplish this?

Thanks,

Matt S.


Answers (6)