我有以下代码每1分钟打开一次记事本。但它没有用。有人可以给我答案吗?
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "My first task scheduler";
TimeTrigger trigger = new TimeTrigger();
trigger.StartBoundary = DateTime.Now;
trigger.Repetition.Interval = TimeSpan.FromMinutes(1);
td.Triggers.Add(trigger);
td.Actions.Add(new ExecAction(@"D:\Tasks\sample.exe", null, null));
ts.RootFolder.RegisterTaskDefinition("TaskName", td);
}
答案 0 :(得分:1)
您可以使用System.Diagnostics.Process类打开记事本: -
Process proc = new Process();
proc.StartInfo = new ProcessStartInfo("notepad.exe");
proc.Start();
它还可以在ProcesStartInfo中打开特定文件: -
proc.StartInfo = new ProcessStartInfo("notepad.exe", "C://temp/log.txt");