Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Looking for a script/method for replacing permissions on files

  • 05-07-2007 11:46AM
    #1
    Closed Accounts Posts: 2,460 ✭✭✭


    Two of our departments are sharing some files at the moment. However sometimes a buyer may put in a file which is owned by them and therefore is not accessible to our marketing department.

    At the moment when I get a call about this problem I just log on and replace all permissions inside the folder to be owned by everyone. I would like this to be automated as it is a recurring problem.


Comments

  • Registered Users, Registered Users 2 Posts: 8,033 ✭✭✭GerardKeating


    Two of our departments are sharing some files at the moment. However sometimes a buyer may put in a file which is owned by them and therefore is not accessible to our marketing department.

    At the moment when I get a call about this problem I just log on and replace all permissions inside the folder to be owned by everyone. I would like this to be automated as it is a recurring problem.

    Have you looked at Windows PowerShell ?


  • Registered Users, Registered Users 2 Posts: 36 declantm


    If you copy the following code into a new batch file (e.g. Permissions.bat) and execute it, that should do the trick
    @Echo off
    setlocal ENABLEEXTENSIONS
    
     REM Change the FolderName to point to the shared directory:
     set FolderName=c:\test
    
     REM Look for all files in all subfolders
     for /f "delims=" %%f in ('dir /a:-d /b /s "%FolderName%"') do @(
    
      REM edit the ACL for each file and grant Everyone change permissions.
      cacls "%%f" /E /G Everyone:C
    
     )
    endlocal
    

    You will need to change the FolderName variable to point to your shared folder name.
    e.g. if the files are kept in the "c:\Shared files" folder then change the text to "set FolderName=c:\Shared files"


  • Registered Users, Registered Users 2 Posts: 816 ✭✭✭Cryos


    Two of our departments are sharing some files at the moment. However sometimes a buyer may put in a file which is owned by them and therefore is not accessible to our marketing department.

    At the moment when I get a call about this problem I just log on and replace all permissions inside the folder to be owned by everyone. I would like this to be automated as it is a recurring problem.

    Hi workaccount,

    What you could do is the following on the Share (e.g \\fileserver\share)

    set the share permissions to Authenticated Users (change) & Domain Admins (full)

    Then under security depending on what way its set, add the 2 departments groups with change access and make sure all permissions thereafter are inheritable. This then means that anyfiles should be accessable by both departments.

    Be carefull if your in a scenaro where you dont want one department accessing anothers files. You may have to manually set inheritable permissions on child folders.


Advertisement