首先:
System.Diagnostics.Process ps = new System.Diagnostics.Process();
ps.StartInfo.UseShellExecute = true;
ps.StartInfo.FileName = "1.bat";
ps.StartInfo.CreateNoWindow = true;
ps.Start();然后:
在1.bat中写入要执行的文件,比如:
at 22:30 a.exe
System.Diagnostics.Process ps = new System.Diagnostics.Process();
ps.StartInfo.UseShellExecute = true;
ps.StartInfo.FileName = "1.bat";
ps.StartInfo.CreateNoWindow = true;
ps.Start();然后:
在1.bat中写入要执行的文件,比如:
at 22:30 a.exe
用at 22:30 1.bat
在1.bat中执行a.exe。
比如:
start 1.exe
增加任务2种方法
1.调用Schedule.ScheduleTimer.AddJob
增加任务,从现在起隔10秒触发一次事件
Schedule.ScheduleTimer TickTimer = new Schedule.ScheduleTimer();
TickTimer.AddJob( new Schedule.SimpleInterval(System.DateTime.Now, TimeSpan.FromSeconds10)), new TickHandler(TickTimer_Elapsed) );
增加任务,每天13:10分触发事件
TickTimer.AddJob( new Schedule.ScheduledTime("Daily", "13:10"), new TickHandler(TickTimer_Elapsed) );
TickTimer.Start();
}
2.先创建Schedule.IScheduledItem对象,调用Schedule.ScheduleTimer.AddJob方法