@echo off
if not exist nevek.txt (goto kilep)
if "%1" == "lofasz" (goto torol)
for /f "tokens=1-3 delims=;" %%A in (nevek.txt) do (
echo user: %%A
echo csoport: %%B
echo jelszo: %%C
net user %%A /add 2>NUL 1>NUL
if %errorlevel% == 2 (echo %%A mar letezik) else (
echo %%A added
)
net user %%A %%C 2>NUL 1>NUL
net localgroup %%B /add 2>NUL 1>NUL
if %errorlevel% == 2 (echo %%B csoport mar letezik) else (
echo %%B added
)
net localgroup %%B %%A /add 2>NUL 1>NUL
if %errorlevel% == 2 (echo %%A mar %%B tagja) else (
echo beraktam %%A %%B
)
)
goto kilep
:torol
for /f "tokens=1-3 delims=;" %%A in (nevek.txt) do (
echo user: %%A
echo csoport: %%B
echo jelszo: %%C
net user %%A /delete 2>NUL 1>NUL
if %errorlevel% == 2 (echo %%A nem volt) else (
echo %%A torolve bazmeg
)
net localgroup %%B /delete 2>NUL 1>NUL
if %errorlevel% == 2 (echo %%B csoport nem volt) else (
echo %%B torolve bazmeg
)
)
:kilep
------ nevek.txt -----
user_1;group_1;abcd
user_2;group_1;abcd
user_3;group_1;abcd
user_4;group_1;abcd
user_5;group_2;abcd
user_6;group_2;abcd
user_7;group_2;abcd
user_8;group_2;abcd