Windows pausing service instead of restarting it when batch file called from task scheduler

batchscheduled-taskstask schedulerwindowswindows 7

I have set up a task in Windows Task Scheduler to run at a specific time each day. The task simply executes a batch file I've created to restart my Windows service. This is the contents of that file:

net stop "MyService"
net start "MyService"

This seems to work well for the most part, but occasionally the service will actually pause itself, rather than stop/start. I will come back to it later on and it will just be sitting there, paused.

Why would task scheduler pause my service, rather than start it, and how can I remedy that?

Best Answer

EXE's converted to a services by utilities like NSSM are fraught with chances of failure.

Even NSSM points this out on their home page:

"...if your application is well-behaved you can configure nssm to absolve all responsibility for restarting it and let Windows take care of recovery actions."

Sounds like your application is not "well behaved".

Either try using NSSM to stop/start and restart the service, or if that doesn't help, rewrite/recompile the program as an actual Windows service.

Related Question