ITK
ITK

Reputation: 163

How to run Pre-made Windows Task Scheduler Task?

How to simply run pre-made task by name without using schtasks.exe as new process?

Should be max 2 line total using namespace + execute pre-made task by name.

I can build a task with C# using TaskScheduler wrapper (which can create, modify, edit) or MS TaskScheduler class which can do the same with a bit more code. Seems all topics has so much extra code that I don't even wanna consider reading 30 lines of code just to end up making new task and running it as every single piece of sample seems to provide.

Asking since: I already have elevated user rights for application and trying to run an update engine at another user profile which has EFS rights again for the update. Running new process ain't gonna be pretty, if I do that.

Upvotes: 1

Views: 184

Answers (1)

user585968
user585968

Reputation:

You are missing the point of Windows Task Scheduler (TS). One does not generally "run" a task, instead one defines one or more triggers (such as a schedule) and lets the TS worry about when to run it.

As mentioned, you should avoid those "wrapper" libraries around TS and instead go right to the source and use the Task Scheduler 1.1 COM library. Just add a reference to it from Visual Studio.

.NET has been designed to interface to COM directly so middlemen are generally not required.

Upvotes: 1

Related Questions