2

Is it possible to run method of class as administrator from process started without administrator privilegies?

For example, I have a method:

void BeginTransfer(string from)
{
//...
}

I need to ask user for administrator privilegies for run this method. Something like total commander ask before copy files to system disk or program files folder. I trying to use PrincipalPermission attribute but it not works for me:

[PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")]

it throws an exception: Failure to request permissions for the account holder (translated from russian)

So what I doing wrong?

shilovk
  • 11,718
  • 17
  • 75
  • 74
Alexey Kulikov
  • 1,097
  • 1
  • 14
  • 38
  • or duplication of http://stackoverflow.com/questions/3583501/c-net-acquire-administrator-rights/3583644#3583644 – silver Jul 19 '15 at 13:04

0 Answers0