Solved

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

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

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

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

This is a guide to the following problem (not exclusive but here) on Windows: Users need our support and we supporters often use global administrative accounts to do this. Using these accounts safely is a real challenge. Any admin who takes se…
Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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