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

Can't create task on Windows Server 2008

Feb 24, 2011 at 8:08 PM

Running on Windows Server 2008 Standard SP1 installed, 32-bit

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.


using (TaskService ts = new TaskService("localhost", tsuser, tsdomain, tspass, false))
Line 20: {
Line 21: TaskDefinition td = ts.NewTask();
Line 22: td.Principal.LogonType = TaskLogonType.ServiceAccount;
Line 23: td.Principal.UserId = "System";

Kind of weird, I already had application deployed and running on another Win2008 box. Not sure if it was SP1 or not. Don't think it was.
But now it's just acting weird. Error doesn't really explain much.
I checked TaskService ts - it is not NULL. ts.RootFolder is "\"

Any help? :)

Feb 25, 2011 at 3:13 AM

Can you check to confirm that ts.HighestSupportedVersion is higher than 1.1 and that the Connected property returns true? If so, then the failure has to be in the base COM object failing to call ITaskScheduler.NewTask(0) whilch shouldn't fail.

Feb 25, 2011 at 1:18 PM

ts.HighestSupportedVersion = 1.1

ts.Connected = true


I'm assuming problem is with ts.HighestSupportedVersion?

Feb 25, 2011 at 5:17 PM

In the constructor for the TaskService, try changing "localhost" to null. Going through the code, it appears that a potential problem may be related to that.


Feb 25, 2011 at 7:13 PM

Thanks for reply dahall,

Unfortunately, the same problem persists :(

Feb 26, 2011 at 7:37 AM

If this is happening only on one machine that is running Task Scheduler 1.1, it could be a permissions problem. You need to have SeBatchLogonRight permissions with the account for this machine. You also may need to check the file permissions on the "%windir%\Tasks" directory.

Feb 28, 2011 at 1:46 PM

Yeah it's related to permissions. I couldn't find SeBatchLogonRight, but I went one group at a time locally, and when finally added RDP and Administrators group - it worked.

Thanks dahall!

Jan 4, 2012 at 7:54 PM


I understand I have a permission problem, becouse I cant see the Tasks list (only the folders).

How can I set the permission to my user, where sould I do it?

Thank you!


Jan 5, 2012 at 1:58 AM

The permissions for enumerating tasks is determined by the account supplied to the constructor of the TaskService class. If not account information is provided, it will run using the permissions of the current user.

Jan 5, 2012 at 7:09 AM

Thank you!

I gave permission to the iis user and its start to work.

(right click on the task ->properties->on the general tab click on change user or group, and add the iis user)

Thank you!