Peter
2021-07-14 14:19:03 UTC
I was updating a batch file I wrote to backup one of my PCs. It kept crashing at a certain point. For two days I tried various things to fix it with no luck. I finally guessed at a fix which does work but I don’t understand what the problem was or why the fix works. Here are a few lines from the batch file showing the original version.
(It’s basically a counter/timer loop. When the counter hits 5 seconds it exits the loop and continues elsewhere in the batch file. It’s the bottom line that caused the crash.)
=================================
:wait-Z
if %counter%==5 goto Start-N
timeout 1 > nul
set /A counter=%counter%+1
if not exist z:\transfer\batch goto wait-Z
=================================
The fix: in the top line and the bottom line I changed “wait-Z” to “wait ZZ”
The same thing happened elsewhere in the batch file with “wait-O” which I had to change to “wait-OO”. The problem does NOT happen with “wait-N”, “wait-P” or “wait-Y”.
I’m just trying to understand what’s wrong with “wait-Z” and why “wait-ZZ” works fine.
Possible clue: this happens on only one of my PCs. It’s a new one I built about two weeks ago. All else seems to be normal with it. Windows 10 Pro 64bit.
Thanks!
(It’s basically a counter/timer loop. When the counter hits 5 seconds it exits the loop and continues elsewhere in the batch file. It’s the bottom line that caused the crash.)
=================================
:wait-Z
if %counter%==5 goto Start-N
timeout 1 > nul
set /A counter=%counter%+1
if not exist z:\transfer\batch goto wait-Z
=================================
The fix: in the top line and the bottom line I changed “wait-Z” to “wait ZZ”
The same thing happened elsewhere in the batch file with “wait-O” which I had to change to “wait-OO”. The problem does NOT happen with “wait-N”, “wait-P” or “wait-Y”.
I’m just trying to understand what’s wrong with “wait-Z” and why “wait-ZZ” works fine.
Possible clue: this happens on only one of my PCs. It’s a new one I built about two weeks ago. All else seems to be normal with it. Windows 10 Pro 64bit.
Thanks!