Detecting if current user has access to the Windows Task Scheduler

Oct 7, 2010 at 12:22 PM

Hello everyone!

Is there any way to detect if current user has access to the Windows Task Scheduler?

I was testing my code on Windows Server 2003. I created one Local User and logged in with that user. Using this user account I was not able to go to the Scheduled Tasks directory. When I tried to create a task through code, I received 0x80070005 (E_ACCESSDENIED) exception code. So I just wanna block such users from creating tasks.

Thank you!

Coordinator
Oct 8, 2010 at 10:43 PM

A TechNet article states: "By default, to schedule a task, you must be a member of the Administrators, Backup Operators, or Server Operators group on the local computer. By default, when creating a scheduled task, you cannot enter a user who belongs to a group that has more rights than the group you belong to. For example, if you are a member of the Backup Operators group on the local computer, you cannot specify a member of the Administrators group when creating a scheduled task."

You should be able to check to see if the current user is a member of those groups to determine access.

Oct 15, 2010 at 11:26 AM

Thank you dahall! Now I get how to get rid of this issue..

Oct 15, 2010 at 12:05 PM

There is one more small issue that I have found.  I tried to find the reason, but I didn't find anything. So I'm discussing that issue in this discussion.

I added one task on 10th Oct with following triggers -

    At 12:00 AM every Sunday, Saturday of every week, starting 10/8/2010

    At 12:00 AM every Monday, Tuesday, Wednesday, Thursday, Friday of every week, starting 10/8/2010

    At 5:00 PM every Monday, Tuesday, Wednesday, Thursday, Friday of every week, starting 10/8/2010

I was checking the task on Tuesday, 12th Oct and it was showing a wrong Next Run Time result i.e. 10/16/2010 12:00:00 AM. (But task was running properly at expected next run time.)

I think this is a bug in Windows Task Scheduler 2.0 and it is using only first trigger from the list to calculate next run time. Do you have any idea?

Thank you!

Coordinator
Oct 18, 2010 at 10:18 PM

It is a known bug and there is a hotfix. See this TechNet article.

Oct 21, 2010 at 1:50 PM

Thanks dahall!