I'm trying to create a login script that uses an array to loop through a set of letters. I've coupled this with adding a counter to move through the array. When using the net use command, I get an error saying the network name can not be found. The end goal is to have the drive letters be listed as A, B, H, I, and so on as needed. I'm sure my syntax is wrong but I can't find an answer.
If I manually substitute the variable with a drive letter I don't get the error. The machine is running Windows Server 2016.
@echo off
set letter[1]="A"
set letter[2]="B"
set letter[3]="H"
set letter[4]="I"
set letter[5]="J"
set letter[6]="K"
set letter[7]="L"
set letter[8]="M"
set letter[9]="N"
set letter[10]="O"
set letter[11]="P"
set letter[12]="Q"
set letter[13]="R"
set letter[14]="S"
set letter[15]="T"
set /A counter=1
ifmember "domain users"
if %errorlevel% == 1 (
net use %%letter[%counter%]%%: \\server\shares
set /A counter+=1
echo "Pass"
)
I expected the output to map the folder to a new drive but instead get "System error 67 has occurred The network name cannot be found."