jring_3770
asked on
Useing a Batch file to set user folder permissions
I am trying to create a batch file that will read a .txt file that lists usernames on each line in the file and create a folder for each username in the file. This part appears to be working correctly. I am having a fit out of gettng the appropriate permissions set on each folder. Each folder should have the following permissions:
%domiain%\%Username%:F %domain%\Administrators:F %domain%\Teachers:F
Here is my batch file:
__________________________ ______
Set ShareFolder=D:\Usertestfol der\2012
Set Domain=SEMS
for /f %%a in (test.txt) do call :process "%%a"
goto :eof
:process
set folder=%~1
set fullpath=%ShareFolder%\%Fo lder%
md "%fullpath%"
echo y|cacls "%fullpath%" /t /c /g %domain%\%folder%:F %domain%\Administrator:F SYSTEM:F %domain%Teachers:F
pause
________________________
Here are my results:
________________________
C:\Documents and Settings\Admin\Desktop>Set ShareFolder=D:\Usertestfol der\2012
C:\Documents and Settings\Admin\Desktop>Set Domain=SEMS
C:\Documents and Settings\Admin\Desktop>for /F %a in (test.txt) do call :process
"%a"
C:\Documents and Settings\Admin\Desktop>cal l :process "AAA_Student"
C:\Documents and Settings\Admin\Desktop>set folder=AAA_Student
C:\Documents and Settings\Admin\Desktop>set fullpath=D:\Usertestfolder \2012\AAA_
Student
C:\Documents and Settings\Admin\Desktop>md "D:\Usertestfolder\2012\AA A_Student"
A subdirectory or file D:\Usertestfolder\2012\AAA _Student already exists.
C:\Documents and Settings\Admin\Desktop>ech o y | cacls "D:\Usertestfolder\2012\
AAA_Student" /t /c /g SEMS\AAA_Student:F SEMS\Administrator:F SYSTEM:F SEMSTeach
ers:F
No mapping between account names and security IDs was done.
C:\Documents and Settings\Admin\Desktop>pau se
Press any key to continue . . .
__________________________ ___
Any Help would be greatly appreciated. BTW this is on Server 2003 OS
%domiain%\%Username%:F %domain%\Administrators:F %domain%\Teachers:F
Here is my batch file:
__________________________
Set ShareFolder=D:\Usertestfol
Set Domain=SEMS
for /f %%a in (test.txt) do call :process "%%a"
goto :eof
:process
set folder=%~1
set fullpath=%ShareFolder%\%Fo
md "%fullpath%"
echo y|cacls "%fullpath%" /t /c /g %domain%\%folder%:F %domain%\Administrator:F SYSTEM:F %domain%Teachers:F
pause
________________________
Here are my results:
________________________
C:\Documents and Settings\Admin\Desktop>Set
C:\Documents and Settings\Admin\Desktop>Set
C:\Documents and Settings\Admin\Desktop>for
"%a"
C:\Documents and Settings\Admin\Desktop>cal
C:\Documents and Settings\Admin\Desktop>set
C:\Documents and Settings\Admin\Desktop>set
Student
C:\Documents and Settings\Admin\Desktop>md "D:\Usertestfolder\2012\AA
A subdirectory or file D:\Usertestfolder\2012\AAA
C:\Documents and Settings\Admin\Desktop>ech
AAA_Student" /t /c /g SEMS\AAA_Student:F SEMS\Administrator:F SYSTEM:F SEMSTeach
ers:F
No mapping between account names and security IDs was done.
C:\Documents and Settings\Admin\Desktop>pau
Press any key to continue . . .
__________________________
Any Help would be greatly appreciated. BTW this is on Server 2003 OS
Change "%domain%Teachers:F" to be "%domain%\Teachers:F"
ASKER
Thanks for the quick response.
I have changed "%domain%Teachers:F" to be "%domain%\Teachers:F" and I am still getting the same result. The folders are being created however they still inherit prmissions from the parent folder instead of recieveing the permissions set by the batch file.
I have changed "%domain%Teachers:F" to be "%domain%\Teachers:F" and I am still getting the same result. The folders are being created however they still inherit prmissions from the parent folder instead of recieveing the permissions set by the batch file.
Are you still getting the "No mapping between account names and security IDs was done." message or just not working?
If you're still getting the message it should mean that the user doesn't exist in the domain.
If you're still getting the message it should mean that the user doesn't exist in the domain.
ASKER
I am still getting "No mapping between account names and security IDs was done." message. i have created a .txt file that contains 3 usernames copy & pasted directy from AD. I would prefer this batch file would gather the usernames from an OU in AD and created the folders for each user and set the permissions %domiain%\%Username%:F %domain%\Administrators:F %domain%\Teachers:F
However I am unsure as to if this is possible.
However I am unsure as to if this is possible.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Popeyediceclay I'll try this and let you know how it goes.
ASKER
You Are The MAN!!! That works great! Thanks ever so much! You just saved me a ton of work.