This is daft behaviour that Microsoft's CMD retains for backwards compatibility all of the way back to the earliest versions of Microsoft's COMMAND. If one command script runs another command script, the first command script is cancelled.
The way to get around this is with the
call built-in command. Simply prefix the command script with
call. This yields the behaviour that you, and I suspect most people, expect: the calling command script resumes execution when the called command script terminates.
You can also use
cmd /c, but note that that's not the same thing.
call just nests command scripts within the same command interpreter.
cmd /c starts up an additional new command interpreter sub-process. Changes made to variables, the working directory, open file handles, and suchlike in the sub-process won't affect its parent. Conversely,
call is portable, should one be using replacement command interpreters, whereas
cmd ties one to a specific command interpreter.
- JP Software. CALL. Take Command / TCC Help.
- "CALL". Windows XP Command-line reference A–Z. TechNet. Microsoft corporation.