Hi,
I have a problem registering a task in windows XP SP3 and run it under system account.
The task is created but when i hit run nothing happens: no entry in log file and "LastRunTime" is Never.
Can anybody tell me what are the correct commands in order to achieve this ?
I have a problem registering a task in windows XP SP3 and run it under system account.
The task is created but when i hit run nothing happens: no entry in log file and "LastRunTime" is Never.
Can anybody tell me what are the correct commands in order to achieve this ?
using (TaskService ts = new TaskService())
{
isVersionOne = ts.HighestSupportedVersion < new Version(1, 2);
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Task";
td.RegistrationInfo.Author = "Me";
td.Principal.UserId = @"System";
td.Principal.LogonType = TaskLogonType.ServiceAccount;
td.Settings.RunOnlyIfLoggedOn = true;
td.Triggers.Add(new DailyTrigger
{
StartBoundary = DateTime.Now,
DaysInterval = 2
});
td.Actions.Add(new ExecAction("\"" + @"C:\ConsoleApplication.exe" + "\""));
var task = ts.RootFolder.RegisterTaskDefinition("Test Task", td, TaskCreation.Create, null, null, TaskLogonType.ServiceAccount, null);
}
Thank you !