take ownership of a file/folder using a script

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Does anyone know how to take ownership of a file using a script?
Or any tools that a script/program could invoke to do this?

Thanks
 
While it doesn't appear to confer "ownership", CACLS can be used to assign Full Control to files and folders. Open a Command Prompt window and enter CACLS /?
 
Hi Doug,

Thanks for the info. I havr already tried using xcacls and cacls but I get
"Access is denied". Maybe i'm doing something wrong?

More info follows:
I have some users on a machine, and I want to delete some of their profile
directories, e.g E:\Users\User1\profile

In explorer, if I try and view the folder, I get "Access denied". However I
can
take ownership via the security tab in explorer and get access that way. (When
I click the security tab, it says "you cannot view or edit permissions, but
you can
take ownership", and it seems to work ok.) However, I need to take ownership
via
script.

I've tried using the (X)CACLS commands such as (where sysadmin is the
adminstrator account):
CACLS E:\Users\User1\profile /P sysadmin F
XCACLS E:\Users\User1\profile /E /G sysadmin:F;O
XCACLS E:\Users\User1\profile /P sysadmin:F;O
XCACLS E:\Users\User1\profile /P sysadmin:;O

But each one just gives me the "access is denied" message.

Any thoughts about this?

thank you
David
 
D said:
Hello,

Does anyone know how to take ownership of a file using a script?
Or any tools that a script/program could invoke to do this?

Thanks
Hi

SubInACL looks like is able to do this:

subinacl /noverbose /file \\server\share\dir /setowner=whoever
subinacl /noverbose /subdirectories \\server\share\dir\* /setowner=whoever

New bug fixed version of SubInACL is available for download...
(Windows 2000, Windows Server 2003, Windows XP)

http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b
 
Hello,

Thanks everyone for your help.
The tool SubInACL worked fantastically.
Thanks!

Regards,
David
 
Back
Top