Having problems trying to create a User Manager type program for windows. At this point, I'm not sure if it's a simple or impossible to fix because all of my attempts to find a fix were useless. (Most likely because of horrible knowledge of programming terms.)
I'm trying to combine some strings and the "for" loop counter into one string and then use the resulting string to call an already stored variable that has the name defined in the final string.
The counter should call specific users already defined in an "array" or array substitute from this tutorial: https://www.youtube.com/watch?v=l0ib2kCaVuA&list=PL69BE3BF7D0BB69C4&index=64
How can I make the string instantUser act like the variable allowed_users[0]?
@echo off
setlocal enabledelayedexpansion
title CP Script
setlocal
:Setup
echo What do you want to do? [#]
echo 1. Fix Users + Groups
echo 2. Configure Firewall + Updates
echo 3. Fix Remote Connection
echo 4. Find Illegal Files
echo 5. Configure Audits
echo 6. Fix Minor -
set COMMAND=
set /p COMMAND=Type input: %=%
If %COMMAND%==1 goto Account
If %COMMAND%==2 goto Basic
If %COMMAND%==3 goto Remote
If %COMMAND%==4 goto Files
If %COMMAND%==5 goto Audits
If %COMMAND%==6 goto Minor
echo Incorrect input & goto Setup
:Account
cls
echo File path to user list-
set DIRECTORY=
set /P DIRECTORY=Type input: %=%
set /p Build=<"%DIRECTORY%"
cls
call create_array allowed_users "," "%Build%"
:: PROBLEM WAS HERE
set /a "allowed_users_length_main=allowed_users_length-1"
For /L %%b In (0,1,%allowed_users_length_main%) Do (
Net User "!allowed_users[%%b]!" /Add
)
:: PROBLEM ENDED HERE
echo.
goto :Setup
:Basic
:Remote
:Files
:Audits
:Minor
endlocal
goto :eof