Hello. I am trying to write a bat file that will take ownership of a folder and it's contents, and change the permissions but i'm not having much luck getting control of the contents of the folder. Here are the steps in windows I would take to accomplish this:
1 - Grant ownership of a specific folder and "replace owner on sumcontainers and objects"
- I can take ownership of the main folder, but not it's contents
2 - Edit the advanced security settings and check the box for "replace all existing inheritable permissions on all descendants with inheritable permissions from this object."
- This step wipes out the original owner from the security tab
3 - Add the original owner back to the security tab with full control.
- This step will allow my administrators group as well as the original owner full rights to the folder.
Changing Ownership / Permissions
Moderator: DosItHelp
-
- Posts: 4
- Joined: 22 Dec 2010 10:33
Re: Changing Ownership / Permissions
I've been doing something similiar to what you have asked for so perhaps the script below will help point you in the right direction. Works on Win XP and Server 2003.
The e:\scripts\AccessdeniedFolders.txt file contains the folder name I want to change permissions on. It also happens to match the domain user account.
The script assumes you want to change permissions on multiple folders.
The e:\scripts\AccessdeniedFolders.txt file contains the folder name I want to change permissions on. It also happens to match the domain user account.
The script assumes you want to change permissions on multiple folders.
Code: Select all
REM Takes ownership of the specified folder for the Administrators group (non-recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do takeown /f e:\profiles\nb%%a /a
REM This grants the Administrator group Full control access to the specified folder (non-recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do cacls e:\profiles\nb%%a /e /g administrators:F
REM This changes the user's Full control access to Change control for the specified folder (non-recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do cacls e:\profiles\nb%%a /e /p rpdomain\nb%%a:C
REM Takes ownership of the specified folder for the Administrators group (recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do takeown /f e:\profiles\nb%%a /a /r /d y
REM This changes the user's Full control access to Change control for the specified folder (recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do cacls e:\profiles\nb%%a /e /p rpdomain\nb%%a:C /t
REM This changes the System's access to Full control for the specified folder (recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do cacls e:\profiles\nb%%a /e /p System:F /t
REM This removes the NCCCUsersL group access from the specified folder (recursive)
for /f %%a in (e:\scripts\AccessdeniedFolders.txt) do cacls e:\profiles\nb%%a /e /r Caldomsms01n\NCCCUsersL
Re: Changing Ownership / Permissions
I have XP Home edition + SP3
I do not have "takeown"
Is this something in XP PRO ?
Alan
I do not have "takeown"
Is this something in XP PRO ?
Alan
-
- Posts: 4
- Joined: 22 Dec 2010 10:33
Re: Changing Ownership / Permissions
Yes, I'm using XP Pro.