Q: Exit processes launched from cmd with cmd exit I wrote a script that launches a cmd window. Cmd window further launches several processes. What I want is that on closing the cmd window manually or using exit command, all processes launched via cmd also get killed.

A: Technically it is not possible to change how the exit command works. What you could do is make your own custom start and exit commands by having something like this:
Start Command Batch File: (context would be start2 program.exe)
start "" "%1"
if exist onExit.txt echo %1>> onExit.txt
if not exist onExit.txt echo %1> onExit.txt

Save that as start2.bat
Exit command BatchFile: (context would just be Exit2)
for /F "tokens=*" %%A in  (onExit.txt) do  (taskkill /f /im "%%A"
exit

Save that as Exit2.bat

What those scripts do is keep track of each program you start with the custom command start2 and then taskkill them on your custom exit. You could have these files in the same directory of the batch file, or you could even have your batch file create these files with echo file contents> file.bat and echo more file contents>> file.bat. This is the best you could probably do without placing the actual cmd Executable in system32, which I would certainly not recommend since many other programs use it. Hope this helps
