What happens when you run a program via service and it stops responding? You can configure the service to automatically restart if it stops responding. You can even set an option that if service was automatically restarted to restart again. But sometimes this functionality doesn’t work as expected.
I mean service could stop every hour and then, eventually, you have to start the service automatically.
If you are dependant on a program whose service is failing regularly you have two options.
- Fix the problem
- Find a way to bypass the problem
Number one is the best solution, you dig in to the problem, find a cause and you fix it. This one is also the most rewarding, you get one of those feelings, wow, I did something well and that makes me feel good.
Number two is more like a bypass, you find a quick solution to fix the problem but you do not fix the cause. You will always know that you didn’t do your best. But you did fix the problem. You see, sometimes there is no other way, there is no time, perhaps software vendor is out of business and you can’t get proper support.
How to restart a windows service automatically
So how do you automatically restart a windows service?
There is a this fine program called NetWrix Services Monitor.
User interface simple, it has only has the features that are needed. Once installed you are able to restart windows services, but not only on the server program is installed on, that would be to easy, you can restart windows services on the server program is installed plus you can restart a service remotely, on remote servers. All the services that you add are being monitored from this fine program.
First you need to Enable Services Monitor, then you set which servers and services you will monitor.
You can set alerting via email (this can be really helpful, either to troubleshoot or to give vendor more data when services stop)
After the service is stopped, the program can notify you via email, start the service, reboot the server and even start a user program. And best of all, it’s very simple to use. It’s doesn’t have unnecessary functions.
Wonderful tool that can save you some time. Did I mention it’s free? You can get it here
How to restart a windows service from a command line?
If you are looking for a way to restart a windows service from a command line, either for use in installation program or for writing up a script, you can use a command called net stop.
To stop the service you would use:
net stop {name of the service}
To start the service you would use:
net start {name of the service}
So to restart a service you would use both at the same time:
net stop {name of the service} && net start {name of the service}
You can include it in a command prompt or even scheduled tasks:
cmd /c „net stop{name of the service} & sc start {name of the service}“
To find a service name, you can type: net start and it will list all the services
You can also use Powershell to restart a service:
Restart-Service
Schreibe einen Kommentar