1
我正在嘗試創建一個計劃任務(使用計劃的任務包裝)每3小時觸發一次。我每天都會安裝任務,但在完成文檔後無法完成任務,請每隔幾個小時運行一次。也不太瞭解LogonType。任何人都可以讓我知道我要去哪裏嗎?計劃任務援助請
private void button1_Click(object sender, EventArgs e)
{
using (TaskService ts = new TaskService())
{
var androback = ts.GetTask("Andro_Inc_Backup");
bool taskExists = androback != null;
if (taskExists)
{
MessageBox.Show("Andromeda incremental backup task already installed");
}
else
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Incremental Backup";
td.Principal.LogonType = TaskLogonType.ServiceAccount;
td.Triggers.Add(new DailyTrigger { DaysInterval = 1 });
td.Actions.Add(new ExecAction("C:\\Rameses\\Program\\Inc_Cloud_Backup.exe", null));
const string taskname = "Inc_Backup";
ts.RootFolder.RegisterTaskDefinition(taskname, td);
MessageBox.Show("Incremental Backup Task Installed");
}
}
}