I'm running a console application on Windows Server 2008. I want it to always run, so I have scheduled it to run at startup via the Task Scheduler. I set up the task so it does not require a login.
Now how to stop it? Task Scheduler has an End Task button under All Running Tasks. But that will abruptly stop the task, which I don't want to do. I have programmed it so that CTRL-C will issue a stop request, and it will stop when it's done what it's doing. (For any .NET devs out there I use Console.CancelKeyPress event.)
Is there any way to trigger a cancel key press event (i.e. CTRL-C) in my app when it was run from the Task Scheduler?
(I know one answer is to make it a Windows Service, which I will do eventually, but I need a short term solution.)