+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Setting permissions on a folder and pushing them down in Coding and Web Development; Hi all, I have been trying to get a script working so that it changes the permissions on a installed ...
  1. #1
    FatBoy's Avatar
    Join Date
    Oct 2007
    Location
    Kent, UK
    Posts
    243
    Thank Post
    52
    Thanked 20 Times in 16 Posts
    Rep Power
    17

    Exclamation Setting permissions on a folder and pushing them down

    Hi all,

    I have been trying to get a script working so that it changes the permissions on a installed program folder (Oxford University Press) so that everyone has read/write permissions to it (Otherwise only admins can run the program). So far I, with a lot of help have this:

    varfolder = "c:\Program Files\Oxford University Press"

    SET fs = WScript.CreateObject("Scripting.FileSystemObject")
    SET WshShell = CreateObject("WScript.Shell")

    If NOT fs.FolderExists(varfolder & "\ok.txt") then 'checks if code should run
    fs.CopyFile "\\servername\share\eSongbirds\MSI\ADsSecurity.dll ", "C:\WINDOWS\system32\" 'copies dll over to PC
    fs.CopyFile "\\servername\share\eSongbirds\MSI\ok.txt", "c:\Program Files\Oxford University Press\" 'copies ok.txt to folder
    WshShell.run "regsvr32 /s C:\WINDOWS\system32\ADsSecurity.dll", True 'registers the dll

    SET objsecurity = createobject("adssecurity") 'invokes the dll
    SET objsd = objsecurity.getsecuritydescriptor("file://" & varfolder) 'picks up varfolder
    SET objdacl = objsd.discretionaryacl 'creates acl

    SET objnewace = createobject("accesscontrolentry") ' makes the ace

    objnewace.trustee = "Everyone" 'who your assigning permission to
    objnewace.accessmask = 2032127 ' full control
    objnewace.acetype = acetype_access_allowed
    objnewace.aceflags = 3 ' files folders and subfolders
    objdacl.addace objnewace 'adds ace to acl

    objsd.discretionaryacl = objdacl
    objsecurity.setsecuritydescriptor objsd

    else
    msgbox("no folder exist")
    End if

    It all works ok apart from it doesn't push the permissons down to the folders and files below, it only adds everyone to the root folder (Oxford University Press) I thought the "objnewace.aceflags = 3" code would do it but it doesn't can anyone help?

    Thanks

  2. #2

    Join Date
    Mar 2008
    Location
    Midlands
    Posts
    119
    Thank Post
    0
    Thanked 21 Times in 20 Posts
    Rep Power
    16
    You could use GPO for this too. Computer Config - Windows settings - Security Settings - File system. If the path does not exist on the server/pc you are editing GPO on just create a dummy folder of it.

    Enjoy!

  3. Thanks to AliG from:

    FatBoy (17th October 2008)

  4. #3

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    I'd definitely do it with the GPO but the script that I've used in the past uses value 2 (ADS_ACEFLAG_INHERIT_ACE) to get the perms inherited.

    The MSDN website gives the definitions of the various flag constants.

  5. #4
    FatBoy's Avatar
    Join Date
    Oct 2007
    Location
    Kent, UK
    Posts
    243
    Thank Post
    52
    Thanked 20 Times in 16 Posts
    Rep Power
    17
    Thanks AliG thats spot on never new about this policy cheers for the info also srochford

  6. #5
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,875
    Thank Post
    295
    Thanked 120 Times in 101 Posts
    Rep Power
    40
    eSongbirds! I recently had the fun job of installing that one around the school. I just made an msi for all the disks and then pushed it out. Didn't have the same trouble as you as we have other progs that require local admin rights to run Grrrr... Good to see that scripts as I may need something like that in the future.

  7. #6
    buzzard's Avatar
    Join Date
    May 2006
    Location
    North West
    Posts
    299
    Thank Post
    103
    Thanked 27 Times in 23 Posts
    Rep Power
    24
    Defo use the GPO much simpler to manage, but beware this can easily be applied to the entire network rather then the few computers you want! Just use the security filtering on the GP to narrow down where it applies.

SHARE:
+ Post New Thread

Similar Threads

  1. Setting permissions with Group Policy
    By cookie_monster in forum Windows
    Replies: 11
    Last Post: 28th May 2010, 11:53 AM
  2. Replies: 0
    Last Post: 19th September 2007, 02:02 PM
  3. Mass setting NTFS permissions
    By localzuk in forum Windows
    Replies: 7
    Last Post: 8th January 2007, 04:23 PM
  4. Non-tech staff setting share permissions
    By ITWombat in forum How do you do....it?
    Replies: 26
    Last Post: 18th July 2006, 10:23 AM
  5. Replies: 4
    Last Post: 21st June 2006, 05:21 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •