The reason I want to do this is…
When an app is started by clicking on it, it becomes a child process of the explorer process. The same is true for all apps that are loaded when Windows starts up.
If you kill the explorer process using the “End Process Tree” context menu option in the task manager, it kills all child processes of the explorer process as well (a quick, brute force way to clean up memory without restarting).
I have two scripts – one that kills a bunch of specific processes, and another that restarts those processes.
Most of the processes/apps in my scripts are loaded at start-up thus they are children of the explorer process. When I kill the explorer process tree, all these process die, as explained earlier.
When I restart these apps using a script, they are no longer children of the explorer process. When I kill the kill the explorer process tree, the apps started by the script do not die.
Now, I know I can kill each process individually using a script. But it would be nice to just kill the explorer processes tree in a script without having to specify the individual apps I want to kill.
So, if I have one script that can start my apps as children of the explorer process, my other script just has to kill the explorer processes tree.
I have a script that does just that. It loops through and kills all the child processes of the explorer process. However it only works on apps that load at start up or are are clicked on.
Also, by preventing these apps from loading at start-up, Windows loads MUCH faster. Later, I click on my script icon to load my apps when needed.
That’s why I want to create a script that can start apps as children of the explorer process.
An interesting side note: I have to postpone killing any command/console processes, otherwise the script may kill itself before getting the rest of the processes.