Hello,
I am using the task scheduler to start a little program which do some database work for me.
A service starts this task with an timer. If the timer is lower than the old, the newer will be used.
When I start the programm it works fine. When the service called it first it works fine. When the service called again it crashs with the following error.
The only thing I get is this:
To update/start the task i do this:
I am using the task scheduler to start a little program which do some database work for me.
A service starts this task with an timer. If the timer is lower than the old, the newer will be used.
When I start the programm it works fine. When the service called it first it works fine. When the service called again it crashs with the following error.
The only thing I get is this:
(32,7):Command:I post some code and hope you can help me. If you need more please ask for more.
Microsoft.Win32.TaskScheduler.V2Interop.IRegisteredTask
RegisterTaskDefinition(System.String,
Microsoft.Win32.TaskScheduler.V2Interop.ITaskDefinition, Int32, System.Object,
System.Object, Microsoft.Win32.TaskScheduler.TaskLogonType, System.Object)
To update/start the task i do this:
public static ExecAction WORKER_ACTION = new ExecAction(@"C:\aPath\Worker\Worker.exe", "", null);
...
this.CreateNewTask("Worker", "", new TimeTrigger(newDate), TaskHelper.WORKER_ACTION);
...
public bool CreateNewTask(string taskname, string description, Trigger trigger, ExecAction action)
{
try
{
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = description;
td.Triggers.Add(trigger);
td.Actions.Add(action);
ts.RootFolder.RegisterTaskDefinition(taskname, td, TaskCreation.CreateOrUpdate, "SYSTEM", null, TaskLogonType.ServiceAccount, null);
}
...
I try it on a Windows Server 2008 R2.