.NET create scheduled task on server fails with E_ACCESSDENIED

后端 未结 4 866
北荒
北荒 2021-01-06 13:35

I have an ASP.NET website (in C#) that takes in user data and then attempts to create a windows scheduled task. Of course, this works great on the DEV machine, but fails to

4条回答
  •  情深已故
    2021-01-06 14:10

    I have been able to solve my particular problem, though not completely. I have still not identified the exact rights needed to create and run scheduled tasks, but the following seems to work:

    1. Add the to the Web.config
    2. Add the IUSR user (which is the user the app will run as using impersonate) to the "Backup Operators" group.

    This gives the application access to the Scheduled Tasks folder so that they can create and run the task.

    We had an additional issue, which was that the tasks were attempting to run as the Local System Account. Unfortunately, only administrators seem to be able to assign the Local System Account as the running user, so we needed to impersonate as an Administrator account, not as a Backup Operator in order to get our code functioning correctly.

提交回复
热议问题