I've a .NET windows service that should start at 7:00 and stop at 23:00 each day, running continuously in background.
While I can code the service so that it sleep between 23 and 7, I would prefer a system configuration (something like cron in unix).
How can I do this on Windows 7?
Note that, if system boot up after 7:00, the service should start immediatly.
1- Create a batch file such as starter.bat and type NET START "SERVICE NAME"
2- Create a Task in Task Scheduler for 7:00 a.m that run batch file every day and remember to check Run task as soon as possible after a scheduled start is missed in Settings tab so it will start even if system boot up after 7 a.m.
Repeat those steps for stoper.bat include NET STOP "SERVICE NAME" for 23:00 p.m
You could use Windows task scheduler for this task or a schedule task.
Also Windows AT command is very similar to Cron in Unix
"The AT command schedules commands and programs to run on a computer at a specified time and date. The Schedule service must be running to use the AT command."
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