Process.Start() and the Process Tree
.net, c#
Solution
Eric is correct: Windows does not expose any method of changing a processes parent. However, if the parent dies, there is no link back to grandparent so you can achieve your goal with an intermediate process that starts the child, then dies.
So: Proc A starts proc B, then proc B starts proc C and immediately dies. When proc B dies, proc C will be a root node on the process tree - proc C will NOT be in proc A's tree after proc B dies.
Problem
How can I use Process.Start(), but have the launched process not in the same process tree as the launching process? Consider this sample console application: ``` using System; using System.Diagnostics; using System.Threading; internal class Program { private static void Main(string[] args) { Console.WriteLine("Starting ie..."); Process.Start("c:\\Program Files\\Internet Explorer\\iexplore.exe", "http://www.google.com"); Console.WriteLine("Waiting for 15 seconds"); Thread.Sleep(15000); Console.WriteLine("Exiting..."); } } ``` When this program exits normally, Internet Explorer will continue to run. However, if during the 15 second sleep period you go to Task Manager and select this program and select "End Process Tree", Internet Explorer will also close. (This is directly related to my question from earlier today that, as yet, has no replies. In Windows XP, when the screen saver process ends, it appears to end the process tree, whereas in Vista, just the screen saver process is ended.)