This project has moved. For the latest updates, please go here.

Problem with accessing Administrator task

Topics: Errors
Dec 4, 2012 at 7:00 AM

Hello everyone,

I am getting UnauthorizedAccessException in following scenario in my application:

  1. Login with a user account which is a part of Administrator group
  2. Launch application by right clicking and selecting Run as administrator option
  3. Create a task in this application instance
  4. Close application
  5. Launch application normally (by double clicking application exe)
  6. Try to edit a task which is created in step 3 (this will result in UnauthorizedAccessException)

Observations: I tried same scenario with Window's Task Scheduler application and it works fine, there is no issue.

Will you please help me to understand what exactly the problem is? and what could be the solution?

Thanks.

Coordinator
Dec 12, 2012 at 6:51 PM

In your scenario, the task is being created under different privileges. I believe the Window's Task Scheduler application always runs as Administrator. To ensure that your application behaves the same, you will need to decorate it with the appropriate attributes that force the UAC to grant Administrator rights or you will have to use the TaskService constructor to provide account information for an Administor account.