Creating home directories

Here is a short script for adding home directories for a user. You can use it in two different ways:

1. Interactive

homedir.bat username

2. Batch

homedir.bat -file userfile.txt

Format for import file (userfile.txt):

user1
user2
.
.

======================= START SCRIPT ===========================
@ECHO OFF
if “%1″==”-file” GOTO FILE
GOTO ADDHOMEDIR

:FILE
if “%2″==”” GOTO NOFILE
Echo Reading from users from %2…
for /f “tokens=*” %%a in (%2) do call :ADDHOMEDIR %%a

goto :EXIT

GOTO EXIT

:ADDHOMEDIR

IF NOT EXIST d:users%1 md d:users%1

cacls d:users%1 /E /T /C /G “DOMAIN%1”:F “DOMAINDomain Admins”:F
chown -r -v -d DOMAIN %1 d:users%1*

GOTO EXIT

:ERROR
echo Folder already exists…
GOTO EXIT

:NOFILE

echo Filename missing…
GOTO EXIT

:EXIT
======================= END SCRIPT ===========================

Comments

Leave a Reply

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)