This might help a little: http://www.robvanderwoude.com/for.php
If you want to go line by line, this would work for reading the text file:
Code:
FOR /f %%a in (users.txt) DO (
ECHO %%a
)
If the users are delimited with commas, you will have to do this:
Code:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "tokens=1,2,3,4 delims=," %%a IN (users.txt) DO (
SET user=%user%%%a
SET firstname=%firstname%%%b
SET lastname=%lastname%%%c
SET group=%group%%%d
REM -- echo the variable names like this:
ECHO !user! - !firstname! - !lastname! - !group!
REM -- or the tokens like this:
ECHO %%a - %%b - %%c - %%d
)
ENDLOCAL
PAUSE
Contents of users.txt delimited with commas:
Code:
roberts, robert, smith, users
janej, jane, jones, administrators
samanthar, sam, richardson, users
peterc, peter, cottontail, administrators
Resources:
http://www.robvanderwoude.com/variableexpansion.php
http://blog.crankybit.com/why-that-b...-isnt-working/
Bookmarks