Invoking System.Diagnostics.Process Start and changing the parent process

  • Thread starter Thread starter Dax
  • Start date Start date
D

Dax

Does anyone know if there's a means by which I can invoke a
Process.Start, then detach the process from the calling process. I
suppose in a nutshell I'm asking if there's a way I can add the new
process to the "explorer" process.

Thanks!
 
Process.Start spawns a separate process. Every process has its own address
space. Once it's launched, the other process doesn't really have any
connection to the spawned process.
 
pedrito said:
Process.Start spawns a separate process. Every process has its own address
space. Once it's launched, the other process doesn't really have any
connection to the spawned process.

Well, yes and no. I don't know the specifics, but Windows does track
which process started which other process. You can see this if you run
SysInternals Process Explorer, which shows the processes in a
hierarchical display, providing that detail.

I would be very surprised if there was a way to change the parent
process after the fact though. It seems to me that this is an integral
part of how the process was started, and so once a process is started
the parent is determined permanently for the lifetime of that process.
I'm not even sure if there's a way in .NET to find out the parent
process of a given process, never mind change it.

I do note that via unmanaged code, you can specify the
PROC_THREAD_ATTRIBUTE_THREAD_PARENT_PROCESS attribute when calling
CreateProcess(). So you can't change the parent, but you can explicitly
declare a parent other than the current parent when the process is first
created.

Again, I don't see anything in .NET that would allow this, but if this
is something that would serve the purpose of the OP, going the unmanaged
route might be worthwhile.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top