Windows batch file - The system cannot find the batch label specified
I would point out that the "Testing 1.2.3..." and "Press any key to continue . . ." lines indicate that execution has successfully gone to the :dozip label and then successfully returned to the caller.
Is the "7za" executable actually a batch file? If I modify my test script to have the helper be a batch file, I get the same error. The fix is to do 'call %zip% %1'
the moral of the story: when calling external programs/batch files in a batch file, use call
call foo.bat
and/or
call %foo%
(Calling one batch from another has been done since the days of DOS, just remember to call)
One possibility, although it seems unlikely, is that command extensions aren't enabled, or up-to-date, and this is interfering with call/goto/label behaviour.
Try:
echo [%cmdextversion%]
and if it's less than [2]
(or empty -- []
) then check to see if cmd.exe
is being invoked with /e:off
, or just run
cmd /e:on
in the console window where you will run this batch file.