rtmcmullen
asked on
Home Directories, take ownership, permission and delete script?
Can this be scripted? I have several servers with home directories, but permissions are different on each one, some only the user has permissions and owns, others are orphaned, others I have to propegate permissions to subcontainers before deleting.
Could this be done with takedown and cacls in a script that pulls directory names from a text or excel file?
Could this be done with takedown and cacls in a script that pulls directory names from a text or excel file?
You can either script a shell run of subinacl to do it, or if you have the resource kit for NT/2k, there is already a script, fileman.vbs that will do it for you...I'll see if I can locate it.
http://www.tek-tips.com/viewthread.cfm?qid=1346443&page=2 is the relative info from fileman.vbs
Here's details on subinacl usage: http://support.microsoft.com/?kbid=265360
ASKER
I never could get subinacl to work on subdirectories.. fileman.vbs similar problems, I only got to work on files....
ASKER
I have these 2 commands which do what I want, I just need to know how to incorporate into a script that pulls from a list:
takeown.exe /R /d y /F C:\users\testuser
echo y| cacls C:\users\testuser /t /g username:f
takeown.exe /R /d y /F C:\users\testuser
echo y| cacls C:\users\testuser /t /g username:f
Something like...
Dim objFSO:Set objFSO=CreateObject("Scrip ting.FileS ystemObjec t")
Dim objShell:Set objShell=CreateObject("Wsc ript.Shell ")
Dim objFile:Set objFile=objFSO.OpenTextFil e("C:\Fold erlist.txt ")
user="YourUser"
Do while not objFile.AtEndOfStream
strData=objFile.ReadLine
objShell.Run "takeown /r /d y /F " & strData
objShell.Run "cmd /c echo y|cacls " & strData & " /t /g " & user & ":f"
Loop
objFile.Close
Set objFSO=Nothing
Set objShell=Nothing
Dim objFSO:Set objFSO=CreateObject("Scrip
Dim objShell:Set objShell=CreateObject("Wsc
Dim objFile:Set objFile=objFSO.OpenTextFil
user="YourUser"
Do while not objFile.AtEndOfStream
strData=objFile.ReadLine
objShell.Run "takeown /r /d y /F " & strData
objShell.Run "cmd /c echo y|cacls " & strData & " /t /g " & user & ":f"
Loop
objFile.Close
Set objFSO=Nothing
Set objShell=Nothing
ASKER
Awesome! Thanks for the super quick ressponse Sirbounty, just what I asked for! If I wanted to delete the said directory, would I add a rmdir /s /q to that? Thanks again :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you again.. you are good!
Happy to help - thanx for the grade!
ASKER
sirbounty, just running into one snag, one some, it is not permissioning some downlevel directories and failing to delete.. any ideas?
you can change the cmd /c to a cmd /k to leave the window open - see if it's getting any errors and then 'stopping' the process... I think cacls uses a /c to continue on errors (access denied).