Solved

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

Posted on 2006-11-28
5
582 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 29

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

Industry Leaders: 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

Security measures require Windows be logged in using Standard User login (not Administrator).  Yet, sometimes an application has to be run “As Administrator” from a Standard User login.  This paper describes how to create a shortcut icon to launch a…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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