Thursday, June 17, 2010

To Create folder and grant permission to user to access this folder and his/her own folder by batch

To Create folder and grant permission to user to access this folder and his/her own folder:

 

Prepare the username into a file call namefile.txt in X:\backup\namefile.txt

 

Batch to create folder name from a name list (Must be same at Windows login name):

 

@echo off

 

for /f %%i in (X:\backup\namefile.txt) do mkdir %%i

 

(Remark: if running in console/command prompt it should be “for /F %i in (X:\backup\namefile.txt) do mkdir %i”)

 

e.g. \\server\backup$\userA

 

To grant permission to the individual folder:

 

@echo off

 

FOR /D %%A IN (*) DO cscript xCACLS.vbs X:\backup\%%A /T /E /G MyDomain\%%A:F

 

 

Print Friendly and PDF
Share/Bookmark

No comments:

Post a Comment