我想创建每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