Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Introduction

Restarting a Windows Service at a particular time is demonstrated in this FAQ article with two jobs that respectively stop and start the Windows Update Service.
The Windows Update Service is used in this example as it is neither system-critical (in the short term) and can be stopped and started by a single command without further input.
It is assumed that JobScheduler running these jobs is configured to run as a service.

...

Note that as presented here the jobs will work on Windows XP systems.
On Vista and Windows 7/8 it is necessary to ensure that JobScheduler is running under a user account with the necessary administrative permissions to start and stop services. It is also necessary that the JobScheduler service is configured to automatically register itself under this user account.
JobScheduler runs by default under the "local system" account on Windows systems, without these permissions. We recommend that JobScheduler is run under another user account with permission to start and stop services.
Note that this will mean that locations where, for example, temporary JobScheduler files are saved will change to this new user's file area.

Stop a Windows service

Paste the following code into a file ./config/live/service_stop.job.xml:

Code Block
languagexml
 <?xml version="1.0" encoding="iso-8859-1"?>
 <job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe stop wuauserv
   ]]></script>
   <run_time>
     <period single_start = "03:00"/&gt;
   </run_time>
 </job>

Start a Windows service

Paste the following code into a file ./config/live/service_start.job.xml:

Code Block
languagexml
 <?xml version="1.0" encoding="iso-8859-1"?>
 <job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe start wuauserv
   ]]></script>
   <run_time>
     <period single_start = "03:02"/>
   </run_time>
 </job>

Instead of using a delay of several minutes in the hope that the first job has been completed before the second starts, we recommend that a third script is used to start
the second job after the first job, should the first one complete successfully.
You could configure the second job as a successor to the first job.

Restart a Windows serivce

Paste the following code into a file ./config/live/service_restart.job.xml:

Code Block
languagexml
<?xml version="1.0" encoding="iso-8859-1"?>
 <job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe stop wuauserv
   ]]></script>
   <run_time>
     <period single_start = "03:00"/>
   </run_time>
   <commands on_exit_code="success">
     <start_job job="service_start"/>
   </commands>
 </job>