1.

Solve : user creation from text file?

Answer»

I want a batch file which will create users. the user names and passwords should be taken from the file.

I can do the following

Quote

@echo off
TITLE User Creation
cls
echo.
echo.
echo #######################################################
echo # #
echo # This is Automatic User Creation Program #
echo # #
echo # Select the OPTION according to your Choice #
echo # #
echo # 1. ADD Users #
echo # #
echo # 2. DELETE Users #
echo # #
echo #######################################################
echo.
echo.
TITLE Enter the choice!
set /P MENU="Enter Your Choice: "
if %MENU%==1 goto add
if %MENU%==2 goto delete

goto error

:add
echo.
echo How much users do you want to add ?
echo.
echo.
TITLE Enter the Number!
set /P usrs="Enter the Number <1-1000> "
if %usrs% LSS 1 goto error
if %usrs% GTR 1000 goto error
cls
echo.
echo.
echo.
echo Enter the prefix you want to use to create the users.
echo.
echo Users will be created in a form PREFIX_NUMBER
echo.
echo.E.g.BNU_1, BNU_2, BNU_3 .....
echo.
echo.
TITLE Enter the Prefix!
set /P prfx="Enter the Prefix: "
echo.
echo.
echo.
echo
echo Adding . . .
echo.
echo.
TITLE Adding Users!
for /L %%i IN ( 1,1,%usrs% ) DO net user %prfx%_%%i Pass123 /ADD >> NUL
echo.
goto doneadd

:delete
echo.
echo How much users do you want to delete ?
echo.
echo.
TITLE Enter the Number!
set /P usrs="Enter the Number <1-1000> "
if %usrs% LSS 1 goto error
if %usrs% GTR 1000 goto error
cls
echo.
echo.
echo.
echo Enter the prefix you want to use to delete the users.
echo.
echo Users will be deleted in the form PREFIX_NUMBER
echo.
echo.E.g.BNU_1, BNU_2, BNU_3 .....
echo.
echo.
TITLE Enter the Prefix!
set /P prfx="Enter the Prefix: "
echo.
echo.
echo Deleting . . .
echo.
echo.
TITLE Deleting Users!
for /L %%i IN ( 1,1,%usrs% ) DO net user %prfx%_%%i /DELETE >> NUL
echo.
goto donedelete

:error
echo.
echo.
echo.
echo wrong entry
echo.
echo.
echo.
TITLE Wrong Entry!
goto exit


:doneadd

echo.
echo.
echo.
echo Users are added
echo.
echo.
echo.
TITLE Users Created!
goto exit

:donedelete
echo.
echo.
echo.
echo Users Deleted
echo.
echo.
echo.
TITLE users Deleted!
goto exit

:exit



Discussion

No Comment Found