Solved

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

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now