windows - Batch file runs fine in command prompt but gives error when double-clicked -
i have batch file accepts store numbers , sets them array , iterates through array. when double click batch file gives error:
256 unexpected @ time.
but when run console/command prompt runs fine.
here code.
@echo off setlocal enabledelayedexpansion set index=0 :getstore set /a index=index + 1 set /p store[%index%]=enter slc store number: :ask set /p answer=do want enter store number (y/n): if /i "%answer%" == "n" ( set length=%index% goto next ) if /i "%answer%" == "y" ( goto getstore ) else goto ask :next /l %%i in (1,1,%length%) ( if %store% lss 256 ( /l %%k in (1,1,5) ping 192.168.!store[%%i]!.%%k -n 1 |find "ttl" ) if %store% gtr 255 ( set /a store=%store% - 255 /l %%k in (1,1,5) ping 10.0.!store[%%i]!.%%k -n 1 |find "ttl" ) )
when double click batch file, new cmd
instance executed, 1 instance store
has not been initialized, line
if %store% lss 256 (
fails %store%
empty.
Comments
Post a Comment