PDA

View Full Version : setting acl's using vbs (W2K)



king_ging
05-14-2002, 12:34 PM
Hi all,

i am trying to write a script which will look in the "Home" directory and look at each folder and set the acl's acording to the name of the folder

what i need now is a way of setting the acl's on folders, so far i found this option:"echo y|cacls c:\EvilTools /T /E /C /G system:F" but it only works when ommiting the echo y| path as it comes back with a file not found error, and if i leave it out i need to enter "y" with every folder

any ideas

cheeers

darkness
05-14-2002, 03:37 PM
You can force ACl's raw onto objects but it's long and real complicated. The common method, even suggested during the vbscripting course by MS suggests using xcacls utility from the resource kit. Basically you do a wscript call executing a xcacls command which you build as a string. I do this to create alot of folders and shortcuts.

I will try to scare up some snipits of code. you can also email me questions direct:


Michael.Mclaughlin@mnsu.edu

Michael McLaughlin

Michael McLaughlin/images/forums/icons/smile.gif
Systems Manager
Minnesota State University Mankato

king_ging
05-14-2002, 04:46 PM
Hi Michael,

thanks for the info, i had found the cacls.exe which works fine from the command prompt but didn't want to work 100% nicely, so i have downloaded a trial version of SUPERcacls.exe but no code to be found

i will have a look at xcacls.exe

i expect that it will be very similar to cacls.exe which has to entered in the format echo y| cacls.exe ........, but when run from script it keeps coming back with file not found as it seems to look for echo and not cacls.exe

many thanks

alex t

darkness
05-14-2002, 04:51 PM
XCacls is in the windows 2k resource kit. The file not found might be a path error. Place the util in the c:\winnt or c:\ and see if that helps.

Good Luck!

Michael McLaughlin/images/forums/icons/smile.gif
Systems Manager
Minnesota State University Mankato

jdharm
05-14-2002, 05:37 PM
The "echo |y" works in batch files OK. It is how you automaticly input the 'y' for 'yes' when running the batch. But since you are using a vbs script, I would think that you should replace this method with the 'send key' method after each cacls command rather than the echo before each command.

Josh

"What we call 'Progress' is the exchange of one nuisance for another nuisance."

king_ging
05-14-2002, 05:42 PM
Dim wsh
Set wsh = WScript.CreateObject("Wscript.Shell")

wsh.Run("echo y| cacls <filename> /g <username> : <permission>")
****************************************
The above doesn't work (filepath no found) but when running from the command prompt or the run option "echo y| cacls <filename> /g <username> : <permission>" it does

the above would work if i delete the "echo Y|" but then i would get promted y/n?

but thanks to your help i found this <a target="_blank" href=http://support.microsoft.com/default.aspx?scid=kb;EN-US;q135268> mickeysoft site </a> and it explains that you can use the /y switch to y the y/n prompt when using the xcacls

many thanks

alex t

king_ging
05-15-2002, 12:42 PM
Hi All,

it works but not adding the domain admins group because of the space in between

any idea how to get past this problem

many thanks

alex t