简体   繁体   中英

Start program with a Scheduled Task on startup with C#?

I must make a new Scheduled Task to start an application on windows startup.
Just like placing it in the "Startup" folder...
But I need to create, enable and disable this task in C#.
How do I do this?

There is a Task Scheduler library available on codeproject.com that might do what you need: http://www.codeproject.com/KB/cs/tsnewlib.aspx

Its an older library that may or may not work with newer versions of windows. At the very least, it should point you in the right direction.

I would recommend doing this as a windows service. It gives you the most control over the life cycle of a task like this. Here is a detailed tutorial. There is also a great wizard in Visual Studio to get you going in a few minutes.

I usually like to create a debug service using the sc tool (see tutorial) that points directly to your debug object as a means of easy debugging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM