Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have four Windows services which start up automatically when the machine starts. Thereafter, I want to restart those services every 8 hours in a particular order.

e.g. Stop s1,s2,s3,s4 and than restart them in some other order like s4,s3,s2,s1. The condition is that I should wait for each service to stop completely before I stop another one.

I would want to write a .BAT or some script. Is it possible to define a scheduled task for 8 hours? This is not there in Advanced tasks. Can I do it using Windows Task Scheduler?

share|improve this question
Out of curiosity, why do you want to restart the services? – mfinni Jun 30 '11 at 10:50
They all get hung after running for almost 12-14 hours. 8 hours is a logical point of start for the new shift to work. We are working on getting this fixed. – Geek Jun 30 '11 at 18:54
up vote 3 down vote accepted

In a batch file:

net stop service4
net stop service3
net stop service2

net start service2
net start service3
net start service4

Assuming you are using xp/2003 or above you could create a scheduled task to run the batch file. Assuming you want to repeat the task every 8 hours, pick a time for it to run, then on the properties of the scheduled task, schedule tab > advanced... > repeat task. Change it to repeat every 8 hours.

share|improve this answer
+1. It doesn't get any easier than this. – joeqwerty Jun 30 '11 at 13:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.