1

Basically I'm writing a tool for my job that replaces a broken file copied incorrectly by a software installation with a working version of the file from another computer.

Part of this tool requires me to take ownership of the folder containing the target file (by default this folder is owned by SYSTEM). I am an admin so I can do this through Explorer with no problem, but the tool that I created is unable to take ownership from SYSTEM, but can take ownership without error if the owner is anyone else (another admin for example)

I already have built a manifest which uses requireAdministrator, and this tool is able to take ownership from SYSTEM on my home computer, but not on my work computer.

I believe this is because UAC is disabled via group policy. Is there any way for me to run this program with admin privileges? Thanks for the help.

Slavic_Donut
  • 51
  • 1
  • 8
  • Does it work if you do not have your program do the ownership change and instead do a `Process.Start` to run the `takeown` command? – Scott Chamberlain Mar 03 '16 at 20:38
  • I could try that but I'm not sure it would make a difference. If the tool is not being run with admin privileges I would imagine I'd end up having the same problem. I suspect that my problem is UAC related. I can give it a shot, though. – Slavic_Donut Mar 03 '16 at 20:53
  • No, given the behaviour you describe, UAC is unlikely to be involved. It is more likely to be a bug in your code, or some other oddity in the environment. Start by checking whether `takeown` works. Also check via `whoami /priv` whether you have `SeTakeOwnershipPrivilege` (it should say "Disabled"). – Harry Johnston Mar 03 '16 at 23:57
  • (Note that there are no circumstances I am aware of in which the existing folder owner can affect whether or not you can take ownership. My best guess at the moment is that it is actually different permissions.) – Harry Johnston Mar 03 '16 at 23:59
  • I am able to run takeown and iCACLS to take ownership and change permissions of a folder, respectively. I could change my program to just use these commands instead but it seems like there should be a better way to do it. I don't think it's a bug in the code because like I said it works perfectly on my home network, the only difference is at home I get a UAC dialog. – Slavic_Donut Mar 04 '16 at 00:03

0 Answers0