我想創建每2分鐘觸發一次的任務計劃程序。 我使用以下使用Microsoft.Win32.TaskScheduler每2分鐘運行一次任務計劃程序
我已經寫了下面的代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32.TaskScheduler;
namespace SchedulerTest1
{
class Program
{
static void Main(string[] args)
{
// Get the service on the local machine
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(new DailyTrigger());
// Create an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction("notepad.exe", "D:\\test.log", null));
// Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition(@"Test", td);
// Remove the task we just created
ts.RootFolder.DeleteTask("Test");
}
}
}
}
我想在每2分鐘運行任務namesapce
。需要什麼來更新我的代碼? 幫我
如果你要在命令行中運行這個...: 的schtasks /創建/ SC分/ MO 2/TN DoThis/TR 「記事本d:\ test.log中」 – 2012-08-01 13:17:39
大概你可以設置SC並在對象屬性的某個地方使用MO。 :) – 2012-08-01 13:18:39
如果不是...... exec shell命令? – 2012-08-01 13:28:38