0

I wrote a tool in C# which is supposed to delete user folders of old users after some security checks.

The problem is although I start the application as administrator (with UAC to minimum settings) the application does not seem to have sufficient rights... I get exceptions which say access denied.

If I try to manually delete the folder in the explorer I get prompted to do this as administrator and I click proceed ("fortsetzen" in my German version) and it works fine, which proves I/my login does have the necessary rights.

If I use cmd.exe with del /S /Q C:\User\{user}" it says access denied as well though...
What do I need to do in order to make it work?
Shouldn't being administrator be enough?

Additional info:
OS: Windows 7 Enterprise successfully joined to a samba domain.
It's all domain users.
User-profiles exist only locally.
I am member of a domain group called "edv" (German equivalent of "IT")
That group is added to the local administrator group of the client, where my application runs.

SOLVED thanks to lzam
Sollution:
I had to do the following things:

  1. Take Ownership
  2. Set Rights
  3. Remove write protection flag
  4. Delete it

For further information on how to do that in C# see my original stackoverflow post here.

2

Most likely, your administrators group actually doesn't have the necessary permissions to delete the folder. When you try to delete the folders through Explorer, it most likely is automatically modifying the ACL to give you the necessary permissions on the folder, before it actually deletes it.

You will probably need to modify your program to change the permissions on the directory (taking ownership if necessary) to allow the deletion.

1
  • Ok that solved it, thanks! For details see post edit. – Ch33f Aug 28 '14 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.