Solved

Home Directories, take ownership, permission and delete script?

Posted on 2007-03-28
13
478 Views
Last Modified: 2011-10-03
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?
0
Comment
Question by:rtmcmullen
  • 8
  • 5
13 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18813060
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.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18813067
http://www.tek-tips.com/viewthread.cfm?qid=1346443&page=2 is the relative info from fileman.vbs
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18813069
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18813073
Here's details on subinacl usage: http://support.microsoft.com/?kbid=265360
0
 

Author Comment

by:rtmcmullen
ID: 18813251
I never could get subinacl to work on subdirectories.. fileman.vbs similar problems, I only got to work on files....
0
 

Author Comment

by:rtmcmullen
ID: 18813256
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
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 67

Expert Comment

by:sirbounty
ID: 18813352
Something like...
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
Dim objFile:Set objFile=objFSO.OpenTextFile("C:\Folderlist.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
0
 

Author Comment

by:rtmcmullen
ID: 18813472
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 :)

0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18813477
rmdir is another internal command, like echo, so pass it also through cmd /c

objShell.Run "cmd /c rmdir /s /q " & strData
0
 

Author Comment

by:rtmcmullen
ID: 18813489
Thank you again.. you are good!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18813502
Happy to help - thanx for the grade!
0
 

Author Comment

by:rtmcmullen
ID: 18816689
sirbounty, just running into one snag, one some, it is not permissioning some downlevel directories and failing to delete.. any ideas?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18816737
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).
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now