CMD - Takeown giving "The data area passed to a system call is too small"

3.9k Views Asked by At

I am writing a script to reset roaming profiles and it is failing at a part which basically:

  1. Changes ownership of a Folder and subfolders (the user profile)
  2. Copies it to a Temp folder
  3. Removes the original

To change ownership I use takeown:

takeown /s \\profile-server /f e:\Profiles\%username% /r /d Y

This is run from a domain admin account so permissions are fine. I then get the following output:

SUCCESS: The file (or folder): "\\profile-server\e$\Profiles\%username%" now owned by user "domain\user".

ERROR: The data area passed to a system call is too small

So it changes ownership of the top most folder but fails at the first sub-item.

I have tried this on 2 computers on the network and it works fine but as soon as I change the computer to the profile server this error comes.

Any ideas?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

In order to rectify this all I had to do was use PsExec in order to run the command, so:

psexec \\profileserver takeown /f e:\Profiles\%username% /r /d Y

And it allowed me to recursively take ownership of all the files.