Book navigation

User Actions Menu

User login

Using a Batch Script to Create Multiple Users

I found this on the Brainbuzz networking forums
and modified it to do a little more.  This requires two files: user.bat
and an excel spreadsheet saved as a text/tab delimited file.  I use it
to add all the new students that show up here every September.
First
the format of the Excel spreadsheet looks like this.  You obviously do
not want to use the first line it is just here for reference.

After entering the info in the spreadsheet save it as a text (tab
Delimited) file and rename the .txt extension with a .bat extension.
The user.bat is as follows...

@Echo OFF

Echo Creating user
net user %1 DefaultPasswordHere /add
net user %1 /fullname:"%2 %3" /scriptpath:kixtart /comment:"%4 %5 %6"

Echo Creating Home Directory
rem map a drive to remote student share first
md u:\"class of %6"\%7\%1 > NUL

echo Assigning permissions to user directory
cacls "u:\class of %6\%7\%1" /e /r student
cacls "u:\class of %6\%7\%1" /e /r everyone
cacls "u:\class of %6\%7\%1" /e /g %1:c
cacls "u:\class of %6\%7\%1" /e /g administrators:f 
cacls "u:\class of %6\%7\%1" /e /g labteacher:r 

echo mapping home directory
net user %1 /homedir:"\\ServerName\students\%4 %5 %6\%7\%1"

echo adding user to appropriate groups
rem this only works on the pdc
net group students %1 /add
net group %6 %1 /add

echo user creation complete

If you want a share for every home directory then you need to add this line.
rmtshare \\ServerName\%1$=j:\%1 /grant %1:c /grant administrators:f /remove everyone /remark:"Users private share" > NUL

All you need to do is double-click on the names.bat and watch it work.