Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Task Scheduler Installer

Tags:

c#

.net

windows

I have a little .exe written in c# .net that I want to run on the server every 24 hours. So naturally I would just use the Windows Task Schedular rather then doing the math myself. I have created the program, but I would like to create an installer that just set everything up. Is there a way to do this with like the Visual Studio set-up projects? If not is there like a powershell / batch script that could be used to run after installation?

Bottom Line: Automate the creation of the task.

like image 508
Brad Semrad Avatar asked Feb 03 '12 21:02

Brad Semrad


1 Answers

You can use a powershell script or batch file to execute schtasks which is a command line interface to the task scheduler.

Then you simply need to run the script in order to setup the scheduled task.

There is also a managed wrapper that allows you to create schedules tasks in C#, if you would rather go that way.

like image 142
Oded Avatar answered Oct 04 '22 14:10

Oded