Make batch file detect that a called child-script in a new window has finished - with child-script-window staying open

171 Views Asked by At

From a parent-(batch-)script, I would like to call a child-(batch-)script which is to open and execute in a new window. However, once the child-script in the new window has finished, the parent-script is supposed to resume with the window of the child-script process staying open so that one could see any error messages that might have occured during the execution of the child-script.

I can call the child-script to open in a different window with

Start /wait "" "C:\data\child_script.bat"

but the parent-script cannot detect when the child-script has finished, when I end the child-script with Exit /B. If I use plain Exit at the end of the child-script then this ends the entire process, i.e. it also closes the parent-window and kills the entire process.

Is there any work-around so that the child-process window can stay open but the parent-script can still detect that the child-script has finished?

1

There are 1 best solutions below

1
user19961021 On

Either:

Start "" /wait "C:\data\child_script.bat" -or- Start /D "C:\data" /wait "child_script.bat"

should work.

For example: Start /D "C:\data" /wait "child_script.bat" && echo echo opens child_script.bat, in a new window but doesn't execute the echo until that window has been closed.