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

Error Scheduling Task on 2008 R2

Sep 7, 2012 at 5:57 PM
Edited Sep 7, 2012 at 5:57 PM

Trying to schedule a task in Global.asax on a 2008 R2 machine.  The task scheduling works fine locally (Win 7), but remotely I get:

[COMException (0x80041318): (42,4):Task:]

System.Runtime.InteropServices.COMException: (42,4):Task:

It seems like this is an error in the XML, but when I import the XML manually in to the Task Scheduler UI it works fine.

Here is the XML:

 

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Author>Project.Name</Author>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2012-09-07T16:52:47.912</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT1H</WaitTimeout>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions>
    <Exec>
      <Command>C:\inetpub\wwwroot\bin\myjob.EXE</Command>
      <Arguments>--job=JobName --params param1="value"</Arguments>
    </Exec>
  </Actions>
</Task>

 

Any thoughts?

Coordinator
Sep 7, 2012 at 8:30 PM

Try removing the '.' from the Author tag. I have seen periods screw things up before.

Sep 7, 2012 at 8:58 PM
Edited Sep 7, 2012 at 8:59 PM

Thanks for the quick response but no luck, just gave that a shot without periods in the Author and still not working.

Sep 7, 2012 at 11:02 PM
Edited Sep 7, 2012 at 11:03 PM

I made some progress when I added a principal block.  I added that block because I tried doing this manually on the machine and exporting and that was the only main difference.

The scheduling is happening in a process running as IIS AppPool\DefaultAppPool right now so not having much luck.  Is the only way to get that to work to change the app pool identity?  Main reason I ask is that this is on an Amazon ElasticBeanstalk machine, so I don't really have the ability to do that unless I start using custom images and I'm trying to avoid that.

Coordinator
Sep 9, 2012 at 7:20 PM
Edited Sep 9, 2012 at 7:22 PM

You can eliminate the Principal block and then use the parameters on the RegisterTaskDefinition method to set those values. The process must have appropriate permissions to connect to the TaskService. There are a number of articles on MSDN that detail what permissions are needed within the host process, when credentials should be provided when connecting to a TaskService instance, and what needs to be done within RegisterTaskDefinition.

Marked as answer by dahall on 4/3/2014 at 11:39 AM