I'm implementing a batch file similar to the Gradle wrapper. The idea is that it will download the main application and run it, without the user having to download and install the application itself.
This is all working fine, and now I'm implementing updating the application. This involves replacing the batch file with a new version of the batch file (which has a new download URL in it, in addition to any changes to the batch file itself).
However, when my application replaces the batch file, this leads to weird results (as discussed in https://stackoverflow.com/a/31257641/1668119 and other answers in that question). Is there a safe way to replace a batch file while it is running that doesn't result in new or removed lines causing issues?