I made a simple c# .net console application. It's a backup script to copy a file to another folder and add the date to the the filename to keep it unique. The script runs perfectly.
However when I schedule it in Windows task scheduler, its status will stay on "running" after started while the application closed already.
I tried ending the main function with an int return value of 0 and I tried to have "System.Environment.Exit(0);" as last line of the application. I also removed all other code just leaving the exit code on to make sure the error was not in my code.
The checkbox "If the running task does not end when requested, force it to stop" is enabled.
All this didn't solve the problem.
I'm running windows server 2016
Anyone know how I can solve this problem?
According to this discussion on TechNet, it may help to wrap your exe in a batch file.
In my experience however, the Task Scheduler view must be actively refreshed, for example by pressing F5. This workaround is also the solution for a similar question on SuperUser.
Probably there is a problem in your application. You can try to hunt down the issue like this:
I did 1-3 on Windows 10 and it is working like expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With