Batch Script to restart service

Posted on

Batch Script to restart service – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about windows, scripting, batch-file, , .

Can anyone help with a peice of batch script to restart an application service at scheduled time.

For example: If the service is “windows firewall ” Then the script should restart this service every day at 09:00 AM and 09:00PM .
Can someone help with complete code.(Assume that there is no dependency of this service on any other service).Any help is greately appreciated.


Solution :

If you go to the services, and open Windows Firewall for example. You can see the service name, mpssvc. The way you would set the service to restart is by putting this in the batch file.

net stop mpssvc
net start mpssvc

You would want to save that to a shared location then add it to the scheduled tasks to run at the time you would like.

OR SC start NameOfService

Leave a Reply

Your email address will not be published.