Skip navigation

JSI Tip 0094 - Adding multiple user accounts.

Below you will find a batch file which provides a simple method of adding multiple user accounts. This batch file does not make use of any non-standard commands. I personally use the resource kit utilities which allow assigning the new user to a group and setting share permissions, but the enclosed batch file does everything else. (You can add a net group command - see %systemroot%\System32\ntcmds.hlp)

Usage: Create a batch file of about 50 entries per the following example:

echo **>>c:\users\JSIAddErrors.log
call JSIAddUser User1 User1Password "Remarks" "User1 Full Name" HomeServer
call JSIAddUser User2 User2Password "Remarks" "User2 Full Name" HomeServer
exit

Requirements:

1. The batch file must be run on the HomeServer.
2. Users home directories are created as hidden shares on HomeServer in C:\USERS\UserName.
    A login script will issue a net use Drive: /home
3. Permissions on C:\USERS are set for Administrators and Backup Operators only.
4. Common files in C:\USERS\default are copied to the users home directory.
5. An cummulative log file of errors is created as C:\USERS\JSIAddErrors.log.

JSIAddUser.cmd

REM JSIAddUser.cmd
REM Usage is Call JSIAddUser UserName Password "Remarks" "FullName" HomeServer
if "%5" == "" goto parms
if exist c:\users\%1 goto dup
md c:\users\%1 >nul
net user %1 %2 /ADD /comment:%3 /fullname:%4 /homedir:\\%5\%1$ >nul
if errorlevel 1 goto dup
net share %1$=c:\users\%1 /Y>nul
CACLS c:\users\%1 /G %1:F /T /E >nul
xcopy c:\users\default\*.* c:\users\%1\ /s /e>nul
goto fin
:dup
Echo %1 and/or c:\users\%1 pre-existing. >>c:\users\JSIAddErrors.log
goto fin
:parms
Echo number of parameters for %1. >>c:\users\JSIAddErrors.log
:fin

See tip 443 for a freeware user wizard.


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish