process tree

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

process tree

Post by MigrationUser »

30 Oct 2008 10:49
sergiu14

Story:
1.Start cmd.exe.
2.execute a batch file a.cmd (which executes a.exe with start /b (doesn't wait for the exe to terminate, and doesn't show the console). The .exe is a C program which contains an infinite loop.
so we have this tree : cmd.exe(from where I launch a.cmd) -> cmd.exe(hidden, executing a.cmd) -> a.exe (infinite loop)

When I close the first cmd.exe, all its children get close. I don't want this to happen. I want the a.exe to keep running.(eg. the process a.exe to be adopted by explorer.exe). Who should I execute from cmd.exe, the a.cmd script?

----------------------------

#2 31 Oct 2008 11:40
Simon Sheppard


It might be easier to just hide the window with cmdow

http://www.commandline.co.uk/cmdow/

----------------------------

#3 31 Oct 2008 12:31
sergiu14


Hello Simon, thanks for post, but I wanted to do that without additional software. How can I do that only using the tools that Windows provides.

----------------------------

#4 31 Oct 2008 12:33
bluesxman


Never experienced this problem, though if I'm spawning an application from a script, and wanting it to stay running, I'll generally engineer the script such that it finishes of its own accord; perhaps closing it with the "x" button kills the process tree, whereas exiting cleanly may have more desirable results...

cmd | *sh | ruby | chef

----------------------------

#5 31 Oct 2008 12:47
Simon Sheppard


I don't think theres anything native that will do exactly what you want, but another approach would be to install it as a background service which you can start and stop as needed.

INSTSRV.EXE
http://support.microsoft.com/?kbid=137890

----------------------------

#6 31 Oct 2008 12:50
sergiu14


If I put in a.cmd "exit 0" at the end, that will terminate all the cmd.exe from the process list, then the process a.exe still remains (no cmd.exe is seen in the process list). But I see the console on the screen(which is probabily used by a.exe), I cannot type anything in it. I saw you post simon, I'll try to make it a service.

----------------------------

#7 31 Oct 2008 14:24
sergiu14


I just can't belive this post : https://www.pcreview.co.uk/threads/kill ... s.2540340/ . That is exactly what I want :D

----------------------------

#8 02 Nov 2008 11:39
Simon Sheppard


Interesting, so starting and stopping the batch file as a service will leave the executable running.

Maybe all you need is to launch the batch file from Start-Run (or a shortcut) rather than from the CMD shell.
That should make the parent process Explorer.exe instead of CMD.exe

Process Explorer will show you exactly how the inheritance between processes is working
https://docs.microsoft.com/en-gb/sysint ... s-explorer
Post Reply