Everything, Everything

2024: J F M A M J J A S O N
2023: J F M A M J J A S O N D
2022: J F M A M J J A S O N D
2021: J F M A M J J A S O N D
2020: J F M A M J J A S O N D
2019: J F M A M J J A S O N D
2018: J F M A M J J A S O N D
2017: J F M A M J J A S O N D
2016: J F M A M J J A S O N D
2015: J F M A M J J A S O N D
2014: J F M A M J J A S O N D
2013: J F M A M J J A S O N D
2012: J F M A M J J A S O N D
2011: J F M A M J J A S O N D
2010: J F M A M J J A S O N D
2009: J F M A M J J A S O N D
2008: J F M A M J J A S O N D
2007: J F M A M J J A S O N D
2006: J F M A M J J A S O N D
2005: J F M A M J J A S O N D
2004: J F M A M J J A S O N D
Legacy Calls
Tuesday 5th September, 2017 23:06 Comments: 0
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.
© Robert Nicholls 2002-2024
The views and opinions expressed on this site do not represent the views of my employer.
HTML5 / CSS3