This project has moved and is read-only. For the latest updates, please go here.

FileNotFoundException during RegisterTaskDefinition?

Topics: Errors
Aug 1, 2015 at 11:03 PM
I have a few people experiencing an issue in my program in which people are reporting a program exception/crash when the program attempts to execute the RegisterTaskDefinition() function.

The following is my code...
Dim taskService As New TaskService

' Where all of my task setup code is. It's too long to mention here so I won't.

taskService.RootFolder.RegisterTaskDefinition("System Restore Checkpoint by System Restore Point Creator", newTask, TaskCreation.CreateOrUpdate, "NT AUTHORITY\System", vbNullString, TaskLogonType.InteractiveToken, vbNullString)
How is the RegisterTaskDefinition() causing an exception on the RootFolder in the Task Scheduler? The RootFolder should always exist so I shouldn't have a problem with this code yet it has some issues on some people's computers. What's going on here?
Aug 6, 2015 at 4:42 AM
First of all, SYSTEM cannot be the user when InteractiveToken is used since SYSTEM cannot run interactively. Please check the documentation on this site to see how to correctly call RegisterTaskDefinition using the SYSTEM account.

If, after making that change, you still experience the error, please let me know which OS versions are running and the status of the account connecting to the TaskService (admin, user, etc.).
Marked as answer by dahall on 9/1/2015 at 9:29 AM
Aug 7, 2015 at 12:44 AM
So something like this instead?
taskService.RootFolder.RegisterTaskDefinition("System Restore Checkpoint by System Restore Point Creator", newTask, TaskCreation.CreateOrUpdate, "NT AUTHORITY\System")
Aug 7, 2015 at 8:19 PM
Marked as answer by dahall on 9/1/2015 at 9:29 AM