Thanks I have found the answer in this board!
Just use:
Just use:
ts.RootFolder.RegisterTaskDefinition("MyTask", td,
TaskCreation.CreateOrUpdate, "SYSTEM", null,
TaskLogonType.ServiceAccount);