Question : VBS Script to remove/set folder inheritance

I need a vbs script that will clear inheritance for all subfolders and files under a specified parent folder.  Then go back and re-allow inheritance for those same subfolders and files.

Some background information on the problem I am having can be found in my previous question here:
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_2003_Active_Directory/Q_23130876.html#a20820026

The only solution is to uncheck allow inheritance, then click apply.  Then check  allow inheritance again and then apply again.  Then all the inherited permissions from the parent folders will be applied.

Now my problem is that there thousands of folders that need this to be done.

According to this article, http://support.microsoft.com/kb/320246/en-us, a vbs script can be written to automate this process.

Can anyone help me with this script?

Answer : VBS Script to remove/set folder inheritance

Hey guys, have a look at SetACL.exe, seems to work better....
http://setacl.sourceforge.net/html/examples.html

This script will use that tool to force "Replace permission entries on all child objects"

'================
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = "C:\temp\temp\Test script\Test\folder3"
strFolder = objFSO.GetFolder(strFolder).ShortPath
strSetACLPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "SetACL.exe"
strSetACLPath = objFSO.GetFile(strSetACLPath).ShortPath
strSetACLLog = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "SetACLLog.txt"
strSetACLLog = objFSO.GetFile(strSetACLLog).ShortPath
Set objLog = objFSO.CreateTextFile(strSetACLLog, True)
objLog.Close
Set objLog = Nothing
strCommand = "cmd /c " & strSetACLPath & " -on " & strFolder & " -ot file -actn ace " & _
           "-ace ""n:S-1-5-32-544;p:full;s:y"" " & _
           "-actn clear -clr ""dacl,sacl"" " & _
           "-actn rstchldrn -rst ""dacl,sacl"" " & _
           "-log " & strSetACLLog
'MsgBox strCommand
objShell.Run strCommand, 0, True
MsgBox "Log file was written to: " & strSetACLLog
'================

Regards,

Rob.
Random Solutions  
 
programming4us programming4us