I want to make the Task Scheduler programmatically. Is there a way to include the exported task from Task Scheduler into C# code to automate task creation?
Asked
Active
Viewed 6,231 times
1
-
Such questions are already there in stack overflow. Please check https://stackoverflow.com/questions/7394806/creating-scheduled-tasks – ManishM Sep 14 '18 at 07:46
-
Possible duplicate of [Creating Scheduled Tasks](https://stackoverflow.com/questions/7394806/creating-scheduled-tasks) – Liam Sep 14 '18 at 07:58
-
Hi @ManishM if you fee la question is a duplicate please flag it as such. See [How should duplicate questions be handled?](https://meta.stackexchange.com/questions/10841/how-should-duplicate-questions-be-handled) – Liam Sep 14 '18 at 07:59
1 Answers
3
Use TaskScheduler 2.8.4 NuGet Package, like this :
TaskService.Instance.RootFolder.ImportTask("IDM", @"D:\Update.xml");

Mojtaba Tajik
- 1,725
- 16
- 34
-
I try that, but in my Task Scheduler, I don't see the created task. Why? – Nemanja Andric Sep 14 '18 at 07:44
-
-
@ Mojtaba Tajik I install exactly that package. The last version. But nothing happened. Can you also test this, to help me to solve this problem? I will appreciate that. Thank you in advance. – Nemanja Andric Sep 14 '18 at 07:59
-
@NemanjaAndric I test it and it work. adding task to scheduler need administrator permission, do you run your program as admin ? – Mojtaba Tajik Sep 14 '18 at 08:02
-
Also if we want to stop task by name, we can do that with this code: TaskService.Instance.FindTask("FlexiAppServerSeviceMonTask").Stop(); – Nemanja Andric Sep 14 '18 at 10:49