Batch script crashing

Posted by TamirGali on Stack Overflow See other posts from Stack Overflow or by TamirGali
Published on 2014-06-08T19:43:41Z Indexed on 2014/06/08 21:24 UTC
Read the original article Hit count: 306

Filed under:

My Batch script keeps crashing with the note:

"set was unexpected at this time"

which I could only see via video recording and checking frame by frame.
here is the script:

@echo off
color 6f
set min=0
set max=25
goto REDIR

:REDIR
set var=0
goto TOP

:TOP
cls
set /a var=%var%+1
set /a rand%var%=%random% %% (max - min + 1)+ min 
if %rand2%==%rand1% set var=0&goto TOP 
if %rand3%==%rand2% set var=1&goto TOP 
if %rand4%==%rand3% set var=2&goto TOP 
if %rand5%==%rand4% set var=3&oto TOP 
if %rand6%==%rand5% set var=4&goto TOP
if %rand7%==%rand6% set var=5&goto TOP 
if %rand8%==%rand7% set var=6&goto TOP 
if %rand9%==%rand8% set var=7&goto TOP 
if %rand10%==%rand9% set var=8&goto TOP 
if %rand11%==%rand10% set var=9&goto TOP 
if %rand12%==%rand11% set var=10&goto TOP 
if %rand13%==%rand12% set var=11&goto TOP 
if %rand14%==%rand13% set var=12&goto TOP 
if %rand15%==%rand14% set var=13&goto TOP 
if %rand16%==%rand15% set var=14&goto TOP 
if %rand17%==%rand16% set var=15&goto TOP 
if %rand18%==%rand17% set var=16&goto TOP 
if %rand19%==%rand18% set var=17&goto TOP 
if %rand20%==%rand19% set var=18&goto TOP 
if %rand21%==%rand20% set var=19&goto TOP 
if %rand22%==%rand21% set var=20&goto TOP 
if %rand23%==%rand22% set var=21&goto TOP 
if %rand24%==%rand23% set var=22&goto TOP 
if %rand25%==%rand24% set var=23&goto TOP 
if %rand26%==%rand25% set var=24&goto TOP
if %var%==26 goto SHOW
goto TOP

:SHOW
cls
echo A=%rand1%
echo B=%rand2%
echo C=%rand3%
echo D=%rand4%
echo E=%rand5%
echo F=%rand6%
echo G=%rand7%
echo H=%rand8%
echo I=%rand9%
echo J=%rand10%
echo K=%rand11%
echo L=%rand12%
echo M=%rand13%
echo N=%rand14%
echo O=%rand15%
echo P=%rand16%
echo Q=%rand17%
echo R=%rand18%
echo S=%rand19%
echo T=%rand20%
echo U=%rand21%
echo V=%rand22%
echo W=%rand23%
echo X=%rand24%
echo Y=%rand25%
echo Z=%rand26%
pause
goto REDIR

© Stack Overflow or respective owner

Related posts about batch-file