I have a batch that I execute that loops back it its beginning again when complete so it can run again. Now the problem is that if this batch is running and I update it, the running batch will stop running. This is obvious since the file does get changed when it is saved. Fair enough.
The various methods I found in this stackoverflow seem good for a single time execution, but won't work if the batch is needing to update itself at each loop:
https://stackoverflow.com/questions/171 ... elf-safely
The ideas I've come up with so far:
- Copy the original batch to a temporary batch and execute that batch. Include a check that if the batch is updated, copy it to another temporary one and execute that batch. Repeat, except overwrite the original temp copy if the batch is updated again. This copies the original batch to 2x temp copies and executes those as needed.
- At the end of the original batch, have the batch run a 'cmd /c copy "batch.bat" "%0" & %0' to copy a new copy of batch and then execute the new batch, effectively looping to the beginning. I'm also wondering if 'start' would be better to use versus 'cmd /c'.