I'm trying to create a batch-File to automate some processes, but as of now, it crashes as soon as it reaches this line
for /L %%i in (1,1,%i%) do (...)
I've tried debugging as much as I could, but only managed to pinpoint the error down to this part. Here's the code leading up to this line:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
.
.
.
set /p amount="[1] One/[2] Multiple "
if /i "%amount:~,1%" EQU "1" goto one
if /i "%amount:~,1%" EQU "2" goto multiple
:multiple
set /a i=0
for /F "usebackq delims=" %%a in (..\multiple.txt) do (
set /a i+=1
set array[!i!]=%%a
)
set /a b=1
echo %i% systems have been detected
for /L %%i in (1,1,%i%) do (
echo System !b!: IP: !array[%%i]!
set /a b+=1
)
echo.
echo Please confirm that the input is correct and all systems have been reset to their factory default
set /p confirm="[O]kay/[E]xit "
if /i "%confirm:~,1%" EQU "O" echo Okay
if /i "%confirm:~,1%" EQU "E" goto exit
echo.
echo What type of system are you trying to set up?
echo [0] CPU-Blade
echo [1] GPU-Blade
echo [2] Optic Server
echo [3] Tool Host
echo [4] Provisioning Server
echo [5] Customer Host
echo [6] Control PC
echo [7] Gateway
echo [8] Cluster File Server
echo [9] Storage Expansion Shelf
set /p system="[0]/[1]/[2]/[3]/[4]/[5]/[6]/[7]/[8]/[9] "
set /a b=1
for /L %%i in (1,1,%i%) do (
echo Resetting Chassis Intrusion for System !b!: !array[%%i]!...
I've thought that maybe the for-Loop executed prior to the crashing one might have some issues with them both using the %%i
, so I tried temporarily changing that to %%e
, with no success.
I also copied another instance of this loop:
for /L %%i in (1,1,%i%) do (
echo System !b!: IP: !array[%%i]!
set /a b+=1
)
pause
Right before the crashing loop, but it executed with no problems. I'm at a complete loss right now, any help or pointers would be greatly appreciated!