현재 C# WPF 프로젝트를 작성 중입니다. 사용자가 Windows 작업 스케줄러에 예약 된 작업을 만들고 추가 할 수있게해야합니다.예약 된 작업 생성
어떻게하면이 일을 할 수 있고 인터넷 검색시 많은 것을 찾지 않아서 지침과 참조를 사용해야 할 필요가 있습니다.
현재 C# WPF 프로젝트를 작성 중입니다. 사용자가 Windows 작업 스케줄러에 예약 된 작업을 만들고 추가 할 수있게해야합니다.예약 된 작업 생성
어떻게하면이 일을 할 수 있고 인터넷 검색시 많은 것을 찾지 않아서 지침과 참조를 사용해야 할 필요가 있습니다.
당신은 Task Scheduler Managed Wrapper를 사용할 수 있습니다
using System;
using Microsoft.Win32.TaskScheduler;
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 { DaysInterval = 2 });
// Create an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction("notepad.exe", "c:\\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");
}
}
}
는 다른 방법이
native API를 사용하거나
Quartz.NET 갈 수 있습니다. 자세한 내용은
this을 참조하십시오. 나
https://www.nuget.org/packages/ASquare.WindowsTaskScheduler/
그것은 잘 유창함 API를 설계하기위한
이 작동합니다.
//This will create Daily trigger to run every 10 minutes for a duration of 18 hours
SchedulerResponse response = WindowTaskScheduler
.Configure()
.CreateTask("TaskName", "C:\\Test.bat")
.RunDaily()
.RunEveryXMinutes(10)
.RunDurationFor(new TimeSpan(18, 0, 0))
.SetStartDate(new DateTime(2015, 8, 8))
.SetStartTime(new TimeSpan(8, 0, 0))
.Execute();
이 정보를 SQL 서버 데이터베이스에 저장할 수 있습니까? – Fearcoder
필요한 항목은 다음과 같습니다. http://msdn.microsoft.com/en-us/library/aa383614(v=vs.85).aspx. 프로그래밍 방식으로 필요한 것을 달성하는 방법에 대한 API, 예제 및 설명. – kroonwijk