Solved

Change Folder Permissions in Bulk

Posted on 2009-07-06
4
534 Views
Last Modified: 2013-12-04
Hello.

Currently I am in a W2K3 Enviroment.  

On one of our shared drives we have a list of Jobs, each which have a folder called COST.  I need to reset permissions on that COST folder, but can't push it down via inheritance.  Is there any way by a gui tool or script I can make those changes.

An Example of the structure is:

\\root\JobFiles\JobNumber1\Cost

Therefor I would like to script something that rests the permissions for these folders

\\root\JobFiles\JobNumber1\Cost
\\root\JobFiles\JobNumber2\Cost
\\root\JobFiles\JobNumber3\Cost


and so forth.
0
Comment
Question by:AaronIT
4 Comments
 
LVL 38

Expert Comment

by:Hypercat (Deb)
ID: 24788900
You could use the cacls.exe command line tool and then script the changes that you need to make.  You can get the applicable switches for the command by running cacls /? at the command line, if you're not familiar with it. You'd still have to identify each folder individually in the script, but at least you could cut and paste the folder paths.
There's also an enhanced tool for Win2K3 SP2, which I've never used:
http://support.microsoft.com/kb/919240 
0
 
LVL 2

Author Comment

by:AaronIT
ID: 24788947
So keeping with my example above...

What would my command be

cacls \\root\JobFiles\JobNumber1\Cost /T

How do I set it to inherit?

Can I also add a group vice a user?
0
 
LVL 84

Accepted Solution

by:
oBdA earned 250 total points
ID: 24789010
Well, this would be a lot easier to answer if you'd say which permissions those Cost folders should have ...
The example below would add *C*hange permissions to all Cost subfolders, leaving the current permissions intact.
Simply enter the following command in a command line.
You can do that safely, it's in test mode and will only echo the cacls commands it would otherwise run:

for /d %a in ("\\root\JobFiles\*.*") do @ECHO cacls.exe "%a\Cost" /t /e /g:YOURDOMAIN\SomeGroup:C

To run it for real, you'd need to leave out the @ECHO.
0
 
LVL 1

Assisted Solution

by:vixtro
vixtro earned 250 total points
ID: 24839782
Agreeing with oBdA - it'd be a lot easier if you could say what you want the permissions on the folders to look like after the script has run.
I use xcacls.vbs from VBScript on my fileserver - I use it to go through and change permissions of subfolders en masse. You can download XCACLS.VBS from here:
http://www.microsoft.com/downloads/details.aspx?familyid=0ad33a24-0616-473c-b103-c35bc2820bda&displaylang=en
You'll have to play around with it a little as i'm not entirely sure exactly what end result you're after. To see the switches for xcacls.vbs, run this from the command prompt:

cscript \\path\to\xcacls.vbs /?

NB: Copy and paste this code into a blank notepad document, and save it with the extension ".vbs" for it to work.



Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
 
Set rootPath = "\\root\jobfiles"
xcaclsPath = "path\to\xcacls.vbs"
 
Set rootFolder = objFSO.GetFolder(rootPath)
 
For Each subfolder in rootFolder.subfolders
  fldrName = subfolder.name
  'Running the next two commands grant MODIFY access to the specified user
  modCmd = "cscript " & xcaclsPath & " " & rootPath & "\" & fldrName & "\Cost /E /G DOMAIN\username:M"
  objShell.Run modCmd, 1, True
  'Running the next two commands turn the INHERIT flag for the folder on.
  inCmd = "cscript " & xcaclsPath & " " & rootPath & "\" & fldrName & "\Cost /E /I ENABLE"
  objShell.Run inCmd, 1, True
Next

Open in new window

0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sweet32 Vulnerability in Microsoft IIS7.5 6 946
SBS 2003 RWW Login 3 42
server core and windows updates 3 51
Migrating files on WS2003SP2 to Azure File Share 7 44
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…
No security measures warrant 100% as a "silver bullet". The truth is we also cannot assume anything but a defensive and vigilance posture. Adopt no trust by default and reveal in assumption. Only assume anonymity or invisibility in the reverse. Safe…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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