Configure a Windows service to restart on a schedule using Task Scheduler.


Currently have to manually restart a Windows service daily, would like to auto schedule a task to restart the service.

Product Line

Pelco Video Management


  • Microsoft Windows platforms
  • Services
  • DS
  • Task Scheduler


Due to operating conditions, a Windows service requires routine or consistent restarts.


  1. Open Notepad (Start > in search type notepad and select when found).

    Note: You may need to run notepad with elevated privileges if you want to save the file to the root of C:\  (right-click and select Run as administrator when found from the search results).
  2. Add the following lines in the open text file:
    • net stop servicenamehere
    • net start servicenamehere

      net stop SereniDsService  /  net start SereniDsService

      • To locate the correct service name, right-click the service in Services and select Properties, use the "Service Name:".
      • Add a /y to the end of the line to stop the service as well as all dependant services.   Example: net stop "DS FrameServer Service" /y
      • If the service is slow to stop it could cause a failure when trying to start the service, add the following command to create a pause between the stop and start of the service(s).  timeout /t 10   (10 = 10 seconds, can change to suite needs).


  1. In Notepad click on the File menu and select Save As.
  2. In the Save As window select your save destination (example C:\), then at the bottom under Save as Type: click the drop down menu and select "All Files (*.*)". 
    Type a name for the file and save with the .BAT extension.

  3. Run the .bat file to verify the service restarts.
    1. Navigate to the saved file and right-click > select Run as administrator.
    2. Verify the command prompt comes up and you see the service stopping and then starting.

  4. Open Task Scheduler (Start > in search type Task Scheduler and select when found).
  5. Once Task Scheduler opens, in the right column window click on Create Task...

  6. In the General tab, type a name for the service. Enable the "Run whether user is logged on or not" and "Run with highest privileges".

  7. Click OK

  8. On theTriggers tab select New...
    1. Begin the task: On a schedule
    2. Settings: Select the option needed...e.g. Daily
    3. Select the Start: day and time the task will start triggering.  If set for Daily, Weekly or Monthly the time configured will be used for the recurring triggers.

    4. Click OK
    5.  On the Actions tab, click New...
      1. Action: Start a program
      2. Program/script: click the Browse... button and navigate to your saved .bat file.

    6. Click OK
    7. Leave the rest of the settings default and slect OK again to create the task.  You will be prompted to enter user credentials with administrative rights if "Run with highest privileges" was selected.
      If running on a DSSRV use the DSServiceUser user credentials. 
    8. Now click on Task Scheduler Library folder in the left column, verify the schedule has been created and is listed.