?
Solved

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

Posted on 2006-11-28
5
Medium Priority
?
584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 30

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently, I read that Microsoft has analysed statistics for their security intelligence report. It revealed: still, the clear majority of windows users do their daily work as administrator. An administrative account is a burden, security-wise. My ar…
OfficeMate Freezes on login or does not load after login credentials are input.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 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