Do you know a way to save the contents of a file into multiple variables in a Batch file?
I have a file called userlist.txt containing information like:
user1:password1
user2:password2
etc.
and i want to save the content of that file in two variables, so i can use these variables on other commands (like automatic creation of users on a server or creation of a bash file for a linux server).
something like this (%%u=user and %%p=password for each line):
echo #!/bin/bash > userStep.sh
echo groupeadd somegroup >> userStep.sh
for /f “delims=” %%u %%p in (%userFile%) do (
mkdir z:\users\%%u
net user %%u %%p /add
cacls z:\users\%%u /E /G %%u:r
cacls z:\users\%%u /E /G %%u:w
echo usereadd -d /srv/users/%%u -g somegroup -N -R -s /sbin/nologin %%a >> userStep.sh
echo echo “%%u:%%p” ^| chpasswd >> userStep.sh
)
any help will be appreciated
message edited by Atrealis
1 Answer