4

I have a service which requires elevated administrative permissions. The service runs fine on Windows XP and Windows 2008r2 but when I run the code which checks to see whether the application is executing under an elevated administrative context on Windows 2012r2 - the result is always false.

I have already tried adding <requestedExecutionLevel level="requireAdministrator" uiAccess="true" /> to the application manifest and this works fine when I run the same code as a console application - but as a service, the application just executes without elevated permissions - failing to perform operations that require the administrative permissions.

Also, I am using the code in the accepted answer here to determine if I am running with elevated permissions.

Community
  • 1
  • 1
NTDLS
  • 4,757
  • 4
  • 44
  • 70
  • 1
    I don't think the conception of elevated and non-elevated modes applies to services (hence the code you are running may not be relevant). For example, if you configure your service to Logon as an administrator, then you automatically have full access to the machine. – sgmoore May 06 '15 at 15:08
  • 3
    Talking about UAC in the context of a service is not meaningful. There isn't any way a service can prompt the user for elevation and the service manager will ignore the manifest. You must configure the service with a user account that has sufficient privileges. The default one is the SYSTEM account, it is highly privileged already. – Hans Passant May 06 '15 at 16:11
  • That makes a lot of sense. Thanks guys - I'll do some more testing. – NTDLS May 06 '15 at 16:48

1 Answers1

0

enter image description here

At least 30 characters need to be present before i can click Save button.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219