Showing posts with label how to create a batch file to restart a service. Show all posts
Showing posts with label how to create a batch file to restart a service. Show all posts

Sunday 26 June 2016

How to schedule a windows service automatic restart?

Or, Schedule windows service restart.
Or, Windows service restart using Windows Task scheduler.

Descriptions:  To schedule a windows service restart, you first need to create .bat script suitable for windows task scheduler and then schedule this .bat script execution schedule using Windows Tasks Scheduler

My Scenario: I want to schedule automatic restart of windows update service.
Below are the steps:
1. Create a .bat file for service restart, please refer the article “http://www.techiessphere.com/2016/06/windows-service-restart-script-suitable.html” for creating this .bat script.
2. Go to Start > Search > Task > Task Scheduler

























3. Click on Create Task








4. In General Tab, Name the task > Select the option “Run whether user is logged on or not” > Change user to Local Admin



















5. In the Triggers Tab, Click on “New




















6. Select the settings and configurations as per your requirements























7. In the Action Tab, Click on “New”



















8. In Action drop-down menu, Select  Start a program” > Browse and select the script that you have created > Click on OK




















That’s enough for creating a task schedule for restarting the service you need, but if you still want to look for any additional parameters to be defined in this task schedule, you may refer the “Conditions” and “Settings” Tab for more.

Thursday 23 June 2016

Windows service restart script suitable for Windows Task scheduler.

Or, How to create a Service Restart .bat script?
Or, .bat script for windows service restart.

Descriptions: To create .bat script suitable for windows task scheduler, first you need to have the service name and then write a small script for that service to be stopped and started.

My Scenario: I want to create a .bat script for restartig windows update services which should compatible to be executed manually by command prompt, by double click or by pointing in Task Scheduler Windows Task management console.

Below are the steps:
1. Go to Run > Services.msc > Search for the service Windows Update > Go to Properties of this service > Copy the name of the service as highlighted in red in below screenshot:


















2. Now open a Notepad > Type the commands as shown in below screenshot.
{Net Stop “wuauserv”}
{Net Start “wuauserv”}












3. Go to File > Click on Save As > Give any name you want with .bat extension > in my case its “WindowsUpdateServiceRestart.bat”.


















5. The .bat file script will look like below.



















Now you can use this script as per the scenario explain above in this article. Let me know if you still need any help on this.. Cheers!