Solved

Batch file (or script) to set permissions on home directory

Posted on 2006-11-28
5
579 Views
Last Modified: 2013-12-04
I have recently migrated users' home directories from one server to another.  I need to set the permissions on the files to the user and securityadmin only.  How would I do this in a batch file (or script) as the user for each directory is different? Thanks.
Ashley
0
Comment
Question by:abshipman
  • 2
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18032960
is the name of the directory related to the username at all?
0
 

Author Comment

by:abshipman
ID: 18032992
Yes.  It is the same as the username.
0
 
LVL 28

Expert Comment

by:serialband
ID: 18033174
You should have used robocopy.exe from the resource kit to make the initial copy.

robocopy /mir /copyall  \\computer1\e$ \\computer2\e$    would have kept all the permissions settings.


Since it's been copied already, use subinacl.exe from from the resource kit to set the owner

cd to the directory.
Assuming the folders are the same as the usernames.
for /d %i in (*) do subinacl /subdirectories %i /setowner=domain\%i  should do the trick.

http://support.microsoft.com/kb/265360 has the details of subinacl.exe and xcacls.exe
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18033480
The built-in cacls.exe may can accomplish this as well...

change to the parent folder (assuming it's setup like x:\Users\User1, x:\Users\User2, etc - change to Users)
cd Users

Then type the following at a command prompt:

for /f "delims=" %a in ('dir /ad /b') do cacls %a /G System:F Domain\%a:F Domain\SecAdmin:F

I addeed the System account in there - never a good idea to remove that, but this should loop through all subfolders and basically replace the existing ACL with 'this' one (Username, System account & SecurityAdmin would have (F)ull access).
0
 

Author Comment

by:abshipman
ID: 18039983
Thanks!  That did it!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In today's information driven age, entrepreneurs have so many great tools and options at their disposal to help turn good ideas into a thriving business. With cloud-based online services, such as Amazon's Web Services (AWS) or Microsoft's Azure, bus…
Many of us in IT utilize a combination of roaming profiles and folder redirection to ensure user information carries over from one workstation to another; in my environment, it was to enable virtualization without needing a separate desktop for each…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question