Take Ownership of a folder - Many folders and many users

Posted on 2007-08-10
Last Modified: 2013-11-05
Hi Guys,

First time posting on here so I apologise if I do anything wrong or don't provide enough info.

What i need to do is simple to explain though:

My users are getting Roaming profile errors after the profile folders were moved from one server to another. The only way to stop these messages is to give ownership of the profile folder to the user (I think this is the only way). Now if a user is called user1 the folder will also be called user1. Is there a quick way to set the ownership of all the folders to the corresponding user?

I hope this makes sense. :-/
Question by:netjets
    LVL 31

    Expert Comment

    yes there's a commandline tool called cacls which configures permissions!
    You can combine it with vbscript to write a procedure....

    See here:

    here are more infos and the download:

    Author Comment

    Thanks for the super fast response.

    I don't know how to write VB scripts (very well). Is there an easier way?
    LVL 32

    Expert Comment

    You can use cacls in a  batch file:
    LVL 32

    Expert Comment

    Another, updated utility -
    LVL 31

    Accepted Solution

    to change many permissons and for each folder custom...i dont think that there's a faster way!

    The script should read the foldername from the profilefolder fro example : JasonBourne
    and then change the permissons so, that the user Jason Bourne has specified rigths on its profile folder!

    It could look like this:

    dim fso, folder, shell
    dim currentUser

    set fso = CreateObject("Scripting.FileSystemObject")
    set shell = CreateObject("Wscript.Shell")
    set folder = fso.GetFolder("D:\UserProfileFolders")   '<---Profile Folder on your server

    for each Subfolder in folder.subfolders
         currentUser = ("C:\cacls.exe ..........." &currentUser ..... & subfolder.folder)   '<---type in here the dos command for cacls.exe

    The best is when u change for one userfolder the permissons with cacls via command line and insert the command variable into the line!

    ("%comspec% /c CACLS.EXE " & Chr(34)& "Z:"_
    & Chr(34)& " /E /G " & Chr(34)&  GrpOrAcct1 & Chr(34)&_
    ":R > C:\TXT\RESULT.TXT")
    LVL 31

    Expert Comment

    the cacls command could look like this:
    cacls.exe profiles\%UserName% /g administrators:f system:f %UserName%:c

    Author Comment

    Thanks man! Genius...Thank you all for your help :-)


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article ( first and run the tool TDSSKiller ( to get rid of the infection. Once done, and if the …
    It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    746 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

    20 Experts available now in Live!

    Get 1:1 Help Now