I recently updated a batch file, originally written by someone else, to perform some extra checks and commands. This involved a sanity check to make sure the user hadn't right clicked and run the script as an administrator (otherwise it created files in system32 and failed to run properly). A simple if statement worked perfectly.
But very similar code seemed to fail later on in the script. I could run a batch file, but unlike running an executable the parent would terminate once the child had completed. The trick is to call the second batch file
. This "calls one batch program from another without stopping the parent batch program" according to Microsoft's documentation.
I think I was vaguely aware of this from messing around with Zenmap's batch files for compilation many years ago. I used call to fix my updated script and then searched online to make sure that was actually the right workaround (and not a coincidence).
I didn't check this, but I suspect I could use cmd.exe with arguments as another workaround. Either way, legacy things like this do still seem to haunt Windows and its developers.
At some point the batch file will be replaced by a PowerShell script, which should be much easier to write and maintain.